How to display qt qml object in QFrame



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

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

    c++

    
        qmlRegisterType<CFineTuneSegmentation>("examples", 1, 0, "ClassName");
    
    
    
           QQmlApplicationEngine engine;
           engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
           QObject *topLevel = engine.rootObjects().value(0);
               QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
    
    
    //       QQuickView view;
    //       view.setSource(QUrl::fromLocalFile("MyItem.qml"));
    //       view.show();
    //       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);
               ui->horizontalLayout_3->addWidget(window);
    

    want to add the qml item to the layout.


  • Lifetime Qt Champion

    Hi,

    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.