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. Basic QQuickitem in a QQuickWindow

Basic QQuickitem in a QQuickWindow

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.5k 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.
  • M Offline
    M Offline
    Martell Malone
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      AFAIK, you need the QQuickView.

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

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

      (Z(:^

      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