Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Drawer type in existing QWidget app
Forum Update on Monday, May 27th 2025

QML Drawer type in existing QWidget app

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 557 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.
  • G Offline
    G Offline
    Gourmet
    wrote on last edited by Gourmet
    #1

    I need add Drawer to existing Android application using QWidgets. I have made following in MainWindow class:

    QQmlApplicationEngine* qqae = new QQmlApplicationEngine(":/RightButtonsBar.qml", this);
    auto ws = qqae->rootObjects();
    qWarning()<<ws.size();
    QQuickWindow* w = (QQuickWindow*)qqae->rootObjects().at(0);
    QWidget* wcontainer = QWidget::createWindowContainer( w, this );
    qWarning()<<wcontainer->geometry();
    

    The RightButtonsBar.qml file:

    import QtQuick 2.2
    import QtQuick.Controls 2.2
    
    ApplicationWindow {
        id: window
        visible: true
        Drawer {
            id: drawer
            width: 0.3 * window.width
            height: window.height - 150
            y: 150
            edge: Qt.RightEdge
            background: Rectangle {
            color: "green"
            }
        }
    }
    

    And... nothing. Application starts but no drawer appearing from the left app side. No console error messages related to this code. qWarning() outputs tell this:

    : (null):0 ((null)): 1
    : (null):0 ((null)): QRect(0,0 100x30)
    

    What I am doing wrong? How should I add Drawer to make it working?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Not a direct answer, but since you are using widgets why not use QQuickWidget ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Not a direct answer, but since you are using widgets why not use QQuickWidget ?

        G Offline
        G Offline
        Gourmet
        wrote on last edited by Gourmet
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Not a direct answer, but since you are using widgets why not use QQuickWidget ?

          G Offline
          G Offline
          Gourmet
          wrote on last edited by Gourmet
          #4

          @SGaist this code:

              QQuickView* qqview = new QQuickView();
              qqview->setSource(QUrl("qrc:/RightButtonsBar.qml"));
              QWidget* wcontainer = QWidget::createWindowContainer( qqview, this );
              qWarning()<<wcontainer->geometry();
          

          Gives following console error:

          : (null):0 ((null)): QQuickView does not support using windows as a root item.
          : If you wish to create your root window from QML, consider using QQmlApplicationEngine instead.
          : (null):0 ((null)): QRect(0,0 100x30)
          
          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