Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QQuickWidget not functioning on Android

QQuickWidget not functioning on Android

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 3 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qt_erik
    wrote on last edited by
    #1

    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();

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qt_erik
      wrote on last edited by
      #2

      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.

      p3c0P 1 Reply Last reply
      0
      • Q qt_erik

        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.

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        @qt_erik Seems closer to this QTBUG-44340.

        157

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qt_erik
          wrote on last edited by
          #4

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

          p3c0P 1 Reply Last reply
          0
          • Q qt_erik

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

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

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

            157

            Q 1 Reply Last reply
            0
            • p3c0P p3c0

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

              Q Offline
              Q Offline
              qt_erik
              wrote on last edited by
              #6

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

              p3c0P 1 Reply Last reply
              0
              • Q qt_erik

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

                p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

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

                157

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qt_erik
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • ivandI Offline
                    ivandI Offline
                    ivand
                    wrote on last edited by ivand
                    #9

                    Thank you for your post.
                    I lost my day with this problem on Qt 5.11.1 today.
                    I can't believe it.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved