Solved What is the "parent" for a QWidget used in QML?
-
A have a Qt widget, say myQWidg, which I'd like to repurpose for use in a QML app. Without myQWidg, the QML app works just fine. When used as a Qt widget outside of QML, the myQWidg works just fine.
However, when I use myQWidg in the QML app, app fails with the error
"QWIdget: Cannot create a QWidget without QApplication"
As near as I can tell, what fails is a custom popup dialog, say myQDialog, that is part of myQWidg. The above error seems to be generated by the first use of myQDialog. The relevant code is
myQDialog temp;
temp.doSometing(someparameter)I think error is triggered by the second, not the first statement.
As near as I can tell, myQtDialog is created with a NULL parent, but myQtDialog requires a QApplication as parent or ancestor.
Hence, my question about parenting. I think things would start working if my creation of myQWidg in QML gave it the QML parent widget.
Any suggestions?
-
Hi,
That's unrelated. Your QML app is likely using QGuiApplication. Change that to QApplication if you want to mix it with widgets.
-
Thanks!! Not sure how I would have figured that out without your pointer.