How to drag a QQuickView Object that is child of other QQuickview Object



  • Hello, i have written a mini program and i'm trying to drag a QQuickView Object that is child of other QQuickview Object.

    This is my code:

    @
    #include <QApplication>
    #include <QQuickView>
    #include <QUrl>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QQuickView *dash= new QQuickView;
    dash->setSource(QUrl("qrc:/ui1.qml"));
    dash->show();
    
    QQuickView *widget= new QQuickView;
    widget->setParent(dash);
    widget->setSource(QUrl("qrc:/widget.qml"));
    widget->show();
    
    return app.exec&#40;&#41;;
    

    }
    @

    and this is the result

    !https://www.dropbox.com/s/rsho0kyoqvj5ytd/Captura.PNG?dl=0()!

    The qmls files are rectangles only. The green rectangle is the Object that i want to drag, the "widget" Object


  • Moderators

    Hi,

    Any reason you want to use QQuickView's ? It would be lot easier if you use one QQuickView to load the QML file and in that QML file you can load components from the other QML files.


Log in to reply
 

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