From d1fa45174b9838e0bf1b781cd32d3810faac931b Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 26 Sep 2020 13:53:04 +0200 Subject: [PATCH] Qt 5.15 incompatibility fixed --- playground/grids/GridQuick.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/playground/grids/GridQuick.cpp b/playground/grids/GridQuick.cpp index b1caaef1..c92c88ef 100644 --- a/playground/grids/GridQuick.cpp +++ b/playground/grids/GridQuick.cpp @@ -71,8 +71,21 @@ GridQuick::~GridQuick() void GridQuick::insert( const QByteArray& colorName, int row, int column, int rowSpan, int columnSpan ) { +#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 ) + /* + We need to create a temporary layout in QML, so that the + object for the attachedProperties is created early + */ + auto layout = createQml( "import QtQuick 2.0\nimport QtQuick.Layouts 1.15\nGridLayout { Rectangle {} }" ); + + auto rectangle = layout->childItems().first(); + rectangle->setParent( nullptr ); + + delete layout; +#else auto rectangle = createQml( "import QtQuick 2.0\nRectangle {}" ); - rectangle->setProperty( "color", QColor( colorName.constData() ) ); +#endif + rectangle->setParent( m_grid ); rectangle->setParentItem( m_grid );