I'm trying to load a QML component from python and then add it to the root item of the my QML tree.
This is documented in various locations, including to some extent in the PySide docs (in the second code block of "Detailed description": http://www.pyside.org/docs/pyside/PySide/QtDeclarative/QDeclarativeComponent.html My code, which worked up until my last upgrade (which bumped PySide to 1.0.6), was as follows: # __qml_view is an instance of QDeclarativeView self.__qml_root = self.__qml_view.rootObject() # Set up the scroll area, this is a class defined in python QtDeclarative.qmlRegisterType(ScrollArea, "ScrollArea", 1, 0, "ScrollArea") scroll_area = QDeclarativeComponent(\ self.__qml_view.engine(),\ "ScrollArea.qml").create() scroll_area.setParentItem(self.__qml_root) The problem is that setParentItem() requires a QDeclarativeItem as its argument, not a QGraphicsObject as it's getting. The code in the docs (which is C rather than Python) shows how to cast the object created by .create(), which seems like it would be the right thing to do for __qml_root, but its not clear to me how I do this in Python. Is it possible? Did rootObject() previously return a QGraphicsObject rather than a QDeclarativeItem? (which is why is worked before). How *should* I set the created item (scroll_area) to be a child of self.__qml_root? Thanks, Henry _______________________________________________ PySide mailing list [email protected] http://lists.pyside.org/listinfo/pyside
