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:

    1. 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.

    2. 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.


  • Moderators

    @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.


  • Moderators

    @qt_erik Did you try loading other component like Rectangle or Button instead of Camera?



  • @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?


  • Moderators

    @qt_erik I don't think so. Does it work without layouts then ?



  • I'm still not certain why this is happening, but I found a work-around for anyone else that might need it:

    1. Display the widget containing the QQuickWidget
    2. Hide the main window widget
      This works for display

    Upon exit from the QQuickWidget containing widget (the camera widget in my case):

    1. Display the main window widget
    2. Hide the QQuickWidget containing widget

    Thanks for trying to help me find a solution, @p3c0


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.