Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

How to add dynamically created QQuickItem to VisualItemModel?



  • Here's the code:

    @

        QQuickItem *miniWindowParent = aMainWindow.rootGui()->rootObject()->findChild<QQuickItem*>("samplersMiniListModel");
    
        Q_ASSERT(miniWindowParent != 0);
    
        mDummyMiniItem->setParentItem(miniWindowParent);
    

    @

    samplersMiniListModel is VisualItemModel in QML.

    And this not works (program crashes on the Q_ASSERT). Reason is that the VisualItemModel isnt QQuickItem*.


    This code works good:

    @
    QObject miniWindowParent = aMainWindow.rootGui()->rootObject()->findChild<QObject>("samplersMiniListModel");

        Q_ASSERT(miniWindowParent != 0);
    
        mDummyMiniItem->setParent(miniWindowParent);
    

    @

    but has no effect (Window dont adds to List). Anyone know how to add QQuickItem* to VisualItemModel ?


Log in to reply