Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Add QQmlComponent into QQuickView
Qt 6.11 is out! See what's new in the release blog

Add QQmlComponent into QQuickView

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    drategon
    wrote on last edited by
    #1

    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()),
            Qt::QueuedConnection);
    
    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(),
    QUrl::fromLocalFile(QmlFile));

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

    @

    1 Reply Last reply
    0
    • T Offline
      T Offline
      taferl
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved