Include QML in a Qt Widget application

  • 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

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

    2. 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->setMinimumWidth(450);
    // qmlWidget->setMinimumHeight(350);

  • Why did you write the same post in different forums? anyway I've answered something here

  • Lifetime Qt Champion

Log in to reply