Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Include QML in a Qt Widget application
mclaus last edited by
Hi – I am attempting to embed a QtQuickView window into a layout on a QMainWindow object via the use of a QWidget::createWindowContainer call. While it is partially working, I am having several difficulties
The QtQuickView application does not respond to mouse events properly when it is embedded in the window, but it does when I display it as a standad-alone window.
I don’t seem to be able to control the placement of the embedded widget without the layout properly. The drawing area on the QtQuickView widget seems to spill over the sides of the space allocated for it, and I don’t seem able to adjust it.
Here my code to create and embed the widget – pretty straightforward. The commented out bits are some things I tried to control the placement of the widget – but it didn’t seem to work.
Anybody have any experience working with these QtQuickView widgets?
// add the QML view to the UI window
qmlView = new QQuickView(QUrl(qmlFileName));
QWidget* qmlWidget = QWidget::createWindowContainer(qmlView, this);
// qmlWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
// qmlWidget->setMinimumHeight(350); ui->horizontalLayout->addWidget(qmlWidget);
Xander84 last edited by
You probably should use a QQuickWidget to integrate Qt Quick in a widget application.
QQuickWidget is a new feature coming with Qt 5.3: "Introduced QQuickWidget for easy and flexible integration of Quick views with QWidget-based UIs."
Since there is a need for this widget I guess the QQuickView is not working properly, but I have never tried it myself.