View in #maya on Slack
@brian_venisky: More Maya/QT stuff… using MayaQWidgetDockableMixin to make a dockable QDialog and I only want it to be able to be docked on the right side
this docks the UI on the right side by default -> self.setDockableParameters(dockable=True, floating=False, area=‘right’, allowedAreas=[‘right’])
but if I undock and drag around it can still be docked on the top, bottom, and left of the viewport
Am I missing something?
(Maya 2016 btw)
@bob.w: Sadly don’t have much experience with that mixin. I know its been funky to work with after the Qt5 upgrade.
Check allowedAreas()
on it
http://doc.qt.io/archives/qt-4.8/qdockwidget.html should help track anything on the Qt-side of things
try setDockableParameters(allowedArea='right')
It looks like allowedAreas
isn’t actually a valid flag, and it will only take one area at a time
@brian_venisky: yeah, allowedAreas didn’t work
and allowedArea=‘right’ throws an error
allowedAreas=‘right’ works
@bob.w: Weird
@brian_venisky: but doesnt work
@bob.w: Whats the error?
@brian_venisky: @brian_venisky uploaded a file: Untitled
@bob.w: did you pass ['right']
or 'right'
@brian_venisky: either
@brian_venisky uploaded a file: Untitled
i guess the not-list one would be correct
@bob.w: Yeah, the mixin code expects a string. But it looks like Qt changed on them
@brian_venisky: perhaps a big ole’ bug then?
@bob.w: Yeah
@brian_venisky: OPEN SOURCE
@bob.w: Indeed. What version of Qt does 2016 ship with?
@brian_venisky: QtCore is 4.8.6
PySide is version 1.2.0
@bob.w: So it looks like Qt 4.8 changed setAllowedArea
, to setAllowedAreas
and autodesk never updated their code
@brian_venisky: yer a wizerd bob
damn autodesk.
or damn Qt
or damn em both
@bob.w:
This adds an allowedAreas
flag that takes a list of strings, and sets the value properly.
Or in gist form: https://gist.github.com/bob-white/2dc65b7613a57f0977ec16d75877ed42
Though I wouldn’t rule out other dumb bugs in there.
@bob.w:
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
class MayaQWidgetDockableMixin(MayaQWidgetDockableMixin):
def setDockableParameters(self, dockable=None, floating=None, area=None, allowedArea=None, width=None, height=None, x=None, y=None, allowedAreas=None, *args, **kwargs):
super(MayaQWidgetDockableMixin, self).setDockableParameters(dockable=None, floating=None, area=None, allowedArea=None, width=None, height=None, x=None, y=None, *args, **kwargs)
dockAreaStrMap = {
'left': Qt.LeftDockWidgetArea,
'right': Qt.RightDockWidgetArea,
'top': Qt.TopDockWidgetArea,
'bottom': Qt.BottomDockWidgetArea,
'all': Qt.AllDockWidgetAreas,
'none': Qt.NoDockWidgetArea, # Note: Not currently supported in maya dockControl command
}
if allowedAreas is not None:
allowedAreas = [dockAreaStrMap.get(allowedArea, Qt.AllDockWidgetAreas) for allowedArea in allowedAreas]
areas = allowedAreas[0]
for area in allowedAreas[1:]:
areas |= area
dockWidget.setAllowedAreas(areas)
Slightly less invasive method. Should behave similar though.
@brian_venisky: trying them out
bah gawd
the gist version worked
i owe you at least 1 cider
probably a lot more than that
@bob.w: glad to help man
@brian_venisky: w does not stand for white tonight
for tonight it stands for WIZARD
thanks a million