We created some Qt controls with PyQt that we wanted to make dockable. Note that we do NOT use the designer or this would be possible with the ‘loadUI’ command (which would have demonstrate we know nothing about UI programming, so we chose this option).
The problem is, controls not created through MEL do not have a path, so they cannot be used by maya commands. So if you create a QDialog with a button, the button path would be ‘MayaWindow||’. So you obviously can’t use it in a command like dockControl.
What we can do, however, is create a dockControl as normal, get it as a QDockWidget, abort its child widget, and replace it with whatever demon spawn QWidget we want to use instead.
import pymel.core as pmc
import maya.OpenMayaUI as mayaUI
import sip
from PyQt4 import QtCore, QtGui
slider = pmc.floatSlider() #some throwaway control, feel free to delete this when you're done.
dock = pmc.dockControl(content=slider, area='left') #Returns the string path to the dock control. The control is a QDockWidget under the hood.
dockPt = mayaUI.MQtUtil.findControl(dock) #Find the pointer to the dock control
dockWidget = sip.wrapinstance(long(dockPt), QtCore.QObject) #Get that pointer as a Qt widget
tedit = QtGui.QTextEdit('Herro', dockWidget) #This is whatever real Qt control you want to dock
dockWidget.setWidget(tedit) #Set the docked widget to be your custom control.
The last thing you need to do is furiously shake both middle fingers at Maya.