Hi there!
I just did a test by adding following lines to the typesystem_core.xml
file of the QCore module:
<add-function signature="wrapInstance(unsigned long, PyTypeObject)"
return-type="PyObject">
<inject-code>
if (Shiboken::ObjectType::checkType((PyTypeObject*)%2)) {
%PYARG_0 = Shiboken::Object::newObject(
(SbkObjectType*)%2,
(void*)%1, false);
}
</inject-code>
</add-function>
This compiled successfully and following code did exactly what I'd expected:
import maya.OpenMayaUI as mui
import PySide.QtCore as QtCore
import PySide.QtGui as QtGui
def getMayaWindow():
#Get the maya main window as a QMainWindow instance
ptr = mui.MQtUtil.mainWindow()
return QtCore.wrapInstance(long(ptr), QtCore.QObject)
class MayaSubWindow(QtGui.QMainWindow):
'My custom window, which i want to parent to the maya main window'
def __init__(self, parent=getMayaWindow()):
#Init my main window, and pass in the maya main window as it's
parent
QtGui.QMainWindow.__init__(self, parent)
#Show my window
myWindow = MayaSubWindow()
myWindow.show()
This is just the exact copy of the code example for PyQt and I just
replaced the sip.wrapinstance call with QtCore.wrapInstance.
I'm not sure if I did the right thing, because I do not know how
shiboken and the typesystem stuff works, but at least the result is what
I expected. Perhaps this might help you for implementing this in the
next PySide release. Would be great! :)
Greets,
Carlo
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside