Add QQmlComponent into QQuickView

  • header file
    QQuickView *m_View;
    QQuickItem *m_No2Item;


    old code qt4

    QString QmlFile = "qml/No2Screen.qml";

    QDeclarativeComponent No2Component(m_View->engine(),
                                          QUrl::fromLocalFile(QmlFile ));
    m_No2Item = qobject_cast<QDeclarativeItem *>(No2Component.create());
    connect(m_No2Item , SIGNAL(hidden()), this, SLOT(destroyNo2Screen()),
    m_View->scene()->addItem(m_No2Item );


    In qt5 :
    I've changed like below, but how to additem since quickView has not scence()->addItem?

    QQmlComponent No2Component(m_View->engine(),

    m_No2Item = qobject_cast<QQuickItem *>(No2Component.create());


  • Hi,
    I have the same problem here! Any news on that issue? How did you solve it?

Log in to reply

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