QQuickWidget not functioning on Android
-
Hi, I just recently updated to Qt 5.4.1 and it seems that what I was doing with QQuickWidget (using it to load a QML source in C++ code) no longer works on Android.
The strange behavior:
-
When I load or instantiate a QQuickWidget to display, it does not show up on the screen. It still functions, as I can hit the buttons (where they used to display) and the actions happen. This tells me the QQuickWidget loads the QML and that part functions.
-
If, when the QQuickWidget is in "focus" (should be displayed) I shut the phone screen down and then bring it back up, I can see the QQuickWidget displayed properly for just a moment, then it brings up the widget that should be behind the QQuickWidget.
The pertinent code looks a little like this (and yes, it worked before I moved up to 5.4.1):
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
this->setLayout(layout);
view = new QQuickWidget(this);
view->setSource(QUrl(QStringLiteral("qrc:/declarative-camera.qml")));
layout->addWidget(view);
this->show(); -
-
Oh, and for fun, I added a standard QLabel to the layout, and it also did not display if the QQuickWidget was also in the layout.
If, on the other hand, I left the QQuickWidget out, the Qlabel displayed like normal.By hiding the QQuickWidget after adding it to the layout, the QLabel will also be displayed.
-
Oh, and for fun, I added a standard QLabel to the layout, and it also did not display if the QQuickWidget was also in the layout.
If, on the other hand, I left the QQuickWidget out, the Qlabel displayed like normal.By hiding the QQuickWidget after adding it to the layout, the QLabel will also be displayed.
@qt_erik Seems closer to this QTBUG-44340.
-
@p3c0 Thanks for that link, but unfortunately, the platform warning does not show up in the application/debug output. It does, actually work, just stays invisible.
-
@p3c0 Oh yes, I tried making very simple QML files, but that didn't change the behavior either. Is there a problem in the 5.4.1 release that doesn't allow for QQuickWidgets to be displayed when they are in the layout of a QWidget?
-
I'm still not certain why this is happening, but I found a work-around for anyone else that might need it:
- Display the widget containing the QQuickWidget
- Hide the main window widget
This works for display
Upon exit from the QQuickWidget containing widget (the camera widget in my case):
- Display the main window widget
- Hide the QQuickWidget containing widget
Thanks for trying to help me find a solution, @p3c0