How to display qt qml object in QFrame

  • want to display a qt quick item in a QFrame
    my code is as follows

    RangeSlider {
                    id: rangeSlider
                    from: 0
                    to: 100
                    first.value: 0
                    second.value: 75


        qmlRegisterType<CFineTuneSegmentation>("examples", 1, 0, "ClassName");
           QQmlApplicationEngine engine;
           QObject *topLevel = engine.rootObjects().value(0);
               QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
    //       QQuickView view;
    //       view.setSource(QUrl::fromLocalFile("MyItem.qml"));
    //       QObject *object = engine.rootObjects();
    //           view->setSource(QUrl::fromLocalFile("D:/swapnil_backup/project/VisionApplications/APP_BIS/main.qml"));
    //       QQuickItem *item = qobject_cast<QQuickItem*>(object);
    //       item->setWidth(500);
    //    QHBoxLayout *grid = new QHBoxLayout;
    //    grid->addWidget(view,100,Qt::AlignCenter);
    //    ui->frame_rangeslider->setLayout(grid);

    want to add the qml item to the layout.

  • Lifetime Qt Champion


    If you want to mix widgets and QML then you should use QQuickWidget.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.