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

contentItem doesn't follow window size

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.2.1
    • Fix Version/s: 5.3.0 RC1
    • Labels:
      None
    • Environment:
      Ubuntu 12.04 64-bit
    • Commits:
      qtdeclarative: 0b2d05093c6fc030d40be8c873ad1e0af9bba8cc

      Description

      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.

        Attachments

          Issue Links

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

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes