Maya 2017 Dockable windows and custom icons



In Maya 2017 you need to inherit from MayaQWidgetDockableMixin to create a dockable window. This in turn parents your custom window (a QMainWindow in my case) to a workspaceControl. I can create a custom icon for my widow if I don’t set it to dockable, but as soon as I do the custom icon is destroyed, and the workspaceControl takes over. There is no access to the icon through the workspaceControl flags. Has anyone solved this?


Have you tried getting the QObject/QWidget for the workspaceControl? Latest PyMEL has utility functions to get them for PySide and PyQt. Send me some UI code. I’ll suffer through it with you. :smiley:


I’m taking a swing from that direction. I will keep you posted.


Well, that was fun… So, when you set dockable to True, the widget gets buried in several layers of other widgets, which requires you to change the widget you’re setting the icon for. So just need to override the show() method to set the window icon on the proper widget when dockable=True:

class testDockUI(mmi.MayaQWidgetDockableMixin, QtWidgets.QMainWindow):

    def __init__(self, parent=None):

        super(testDockUI, self).__init__(parent)
        self.setWindowTitle('Test Dock UI')

        pixMap = QtGui.QPixmap(12, 12)
        self.iconData = QtGui.QIcon(pixMap)
    def show(self, *args, **kwargs):
        super(testDockUI, self).show(*args, **kwargs)
        if 'dockable' in kwargs:
            if kwargs['dockable']:
                QtWidgets.QWidget.setWindowIcon(self.parent().parent().parent().parent().parent(), self.iconData)

Unfortunately, after docking/undocking, the icon gets reset. Can’t figure out where that’s happening to set it back again.


Thanks for looking at this Mile. It pains me to see so much digging for the parent :slight_smile:
There should be a dockTriggered event or something like that to look for. I’m going to work with this a bit and will report back.


I did find this method which seems to eliminate the need for parent(). However it requires you wrap a workspaceControl as a QT object.
Docking concept courtesy of Lior ben horin
name = ‘Chickens’
main_control = pm.workspaceControl(name, iw=300, ttc=[“AttributeEditor”, -1], li=False, mw=True, wp=‘preferred’, label = “Chickens”)
control_widget = omui.MQtUtil.findControl(name)

control_wrap = wrapInstance(long(control_widget), QtWidgets.QWidget)

pixMap = QtGui.QPixmap(12, 12)
iconData = QtGui.QIcon(pixMap)
v = control_wrap.window()


Ah, gotcha. So you’re just using the workspaceControl command now instead of the MayaQWidgetDockableMixin. Definitely like that approach more. :smiley:


I just realized that sets the icon for several Maya windows. I think I need to step down by one.


It looks like the parent() method does the same.


Have you guys been successful in using MayaQWidgetDockableMixin with Maya 2018.1?
My UI is quite complex and doesn’t update properly. If I dick/dock it around back and forth, eventually the UI is frozen. If I grab the edge of the UI and slightly resize it, a force-refresh seems to be initiated. But not always is the UI responsive and will require another resize nudge in order to properly update. Is this just me - or does anyone else see this too?


I moved away from the MayaQWidgetDockableMixin. I’m using something like this now.


I’m currently running into this. The UI doesn’t update when I repopulate a QTreeView and it won’t take any of my custom style sheets.