Unsolved QML Drawer type in existing QWidget app
-
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?
-
Hi,
Not a direct answer, but since you are using widgets why not use QQuickWidget ?
-
This post is deleted! -
@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)