Basic QQuickitem in a QQuickWindow



  • Hi guys,

    @

    QGuiApplication app( argc, argv );

    QQuickWindow window;
    QQmlEngine engine;
    QQmlComponent component(&engine, QUrl::fromLocalFile(QLatin1String("qml/main.qml")));
    
    QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
    item->setParentItem(window.contentItem());
    qDebug() << item;
    
    window.show();
    
    return app.exec()
    

    @

    The following code wont run correctly.
    I get a blank window even though my qquickitem is an item that fills the parent and has a rectangle?

    An ideas?


  • Moderators

    AFAIK, you need the QQuickView.

    Another thing: use
    @
    ::setProperty("parent", window.contentItem());
    @

    For some reason, ::setParent() tends not to work.


Log in to reply
 

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