Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-36938

contentItem doesn't follow window size

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.3.0 RC1
    • 5.2.1
    • None
    • Ubuntu 12.04 64-bit
    • qtdeclarative: 0b2d05093c6fc030d40be8c873ad1e0af9bba8cc

      We have a control that reparents itself to the root item (window's contentItem) when it's opened. This seems to work fine, but the unit tests fail because the root item has a zero width and height.

      #include <QtCore>
      #include <QtQuick>
      
      int main(int argc, char* argv[])
      {
          QGuiApplication app(argc, argv);
      
          QQmlEngine engine;
          QQuickWindow window;
          window.setWidth(400);
          window.setHeight(400);
          QQmlComponent component(&engine);
          component.setData(QByteArray("import QtQuick 2.0\n Rectangle { color: 'red'; anchors.fill: parent }"), QUrl());
          QObject *object = component.create();
          qobject_cast<QQuickItem*>(object)->setParentItem(window.contentItem());
          qDebug() << object << window.contentItem()->width() << window.contentItem()->height();
      
          window.show();
          return app.exec();
      }
      

      QQuickRectangle(0x1c10490) 0 0

      Moving the initContentItem() call to the end of QQuickWindowPrivate::init(QQuickWindow *c) seems to be a workaround.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes