aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicklayouts/qquicklayout.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Provide effective size policy of Layout in its attached propertiesSanthosh Kumar2025-10-121-0/+4
| | | | | | | | | | | | | | | The QML Layout, by default, has an effective size policy for shrinking and expanding. But its attached properties (Layout.fillHeight/Layout.fillWidth) don't reflect the same. This patch provides an effective size policy of the Layout in its corresponding attached properties (Layout.fillWidth/Layout.fillHeight), and the same has been updated in the documentation. Fixes: QTBUG-139699 Pick-to: 6.10 6.8 6.5 Change-Id: I133fc8161a321678aaeb160aabf3065112dea32a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Set explicit default security level of all files with default securityJan Arve Sæther2025-09-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The files (folders) already processed are listed in each issue in epic QTBUG-134547 These files were processed half a year ago. In order to make it clear that all of these files are already processed, mark them with an explicit default security header. For the record, this was generated with this script: find -E . -regex ".*\.(cpp|h|hpp|mm|qml|js)$" | xargs python3 ~/bin/add-cra-header.py in the folders listed in each subtask of QTBUG-134547 (add-cra-header.py only exist at my desktop, but it simply adds the default security header if it doesn't already have any existing security header) QUIP: 23 Fixes: QTBUG-134547 Pick-to: 6.10 6.9 6.8 Change-Id: Ieb8c78ea6561fdbdd27c7b13185ece853eedf80f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Allow recursive layout of ApplicationWindowTor Arne Vestbø2025-07-081-1/+19
| | | | | | | | | | | | | The safe areas require recursive layouting of the ApplicationWindow menu bar, header, and footer (in particular). We added guards preventing that in 6dc95399797de4ec27984956df1fa587f4eb18ba, to fix QTBUG-87708, but the fix for that can be in QQuickLayout itself. Pick-to: 6.10 Task-number: QTBUG-87708 Change-Id: I0dc25d779fe76619591f35063826d50dff2e3d28 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Docs: Fix typoPaul Wicking2024-11-071-1/+1
| | | | | | | Pick-to: 6.8 Fixes: QTBUG-130900 Change-Id: I89ed8b8e75cc3401fa9b43277fce9e06c0e75549 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* qmllint/quick: rename attached type warnings to be uniformSami Shalayel2024-08-081-1/+1
| | | | | | | | | | | | Rename runtime warnings and qmllint warnings to be uniform, instead of having many different formulations for the same problem. This makes it easier to document them, at least for the qmllint warning documentation. Pick-to: 6.7 6.8 Task-number: QTBUG-118112 Change-Id: Iabb3a5fb0679523764b9f2fe2d99f4eb93a13c88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix polish issue in the quick layoutSanthosh Kumar2024-06-191-1/+2
| | | | | | | | | | | | | | | | | | The patch 3fa4719789921ff8be440ec760d8b9ab569758eb skip geometry change of layout items when it has already been invalidated. This can cause problems when we have nested layouts, as the dirty flag set in the child layout during invalidate blocks further rearranging its items (i.e. setting geometry to its items). This patch fixes it by allowing rearrange when the parent item is a layout by itself. For other cases (i.e. not the nested layout), the child layout schedules the polish, and this polish takes care of further rearranging its items. Fixes: QTBUG-125481 Pick-to: 6.8 6.7 Change-Id: I86c5b584e27fbe71b3e740fe7b3fdb0f3ac7ae14 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Make the default layout size policy configurable at the component levelSanthosh Kumar2024-05-301-1/+31
| | | | | | | | | | | | | | The default size policy that can be set through application attribute affects globally and there are no configurations provided at the component level to opt-out. This makes it inflexible for the user who wants different behavior at the component level. This patch relaxes the above limitation by adding support to configure default layout size policy at the component level. Task-number: QTBUG-117597 Change-Id: Ic4ea3adbd6f3056bffca5d22690b968c7b6296f0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Enable layouts to respect other size policies than Fixed and PreferredJan Arve Sæther2024-05-281-14/+14
| | | | | | | | | | If no Layout.fillWidth/fillHeight is set, it will fallback to the default built-in size policies, which might be e.g. Expanding or Minimum Task-number: QTBUG-117597 Change-Id: I3cd43cdfb6b4beaefedb81605f52794afba55641 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Fix binding loop and polish issue in quick layoutSanthosh Kumar2024-04-091-14/+10
| | | | | | | | | | | | | | | | | | | | | The quick layout item caused a binding loop issue when layout item sizes were updated in between polish. This has been fixed by not allowing rearrange during geometry change, if the layout is already dirty due to polish event. There is also a polish issue due to the child item not being invalidated and it can lead to skipping the corresponding item box size calculation. This patch invalidates all the items in the rearrange list of the layout and finally, invalidates the engine and layout. The threshold limit to trigger layout polish has also been removed now. Fixes: QTBUG-117899 Fixes: QTBUG-118511 Pick-to: 6.7 6.6 6.5 Change-Id: Ie5713f51ed9e428786046bb06a822e5668beebb0 Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Use Qt::AA_QtQuickUseDefaultSizePolicy to apply size policy for layoutSanthosh Kumar2024-03-051-8/+18
| | | | | | | | | | | | | The default size policy that need to be applied for quick items within the layout has been changed as opt-in. This further require layout to consider Qt::AA_QtQuickUseDefaultSizePolicy attribute and the same been tested for set before applying those size policies. Task-number: QTBUG-117597 Pick-to: 6.7 Change-Id: Idbd27f8cd1ffbfe7631e953c787234f9f1e5b0e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Revert "Adapt layouts to take advantage of new size policy information"Santhosh Kumar2024-02-291-18/+8
| | | | | | | | | | | | | This reverts commit dd72694b6046d98a64bd99361ed9cb4613af78f8. Reason for revert: This is needed in order to rename AA_QtQuickDontUseDefaultSizePolicy to AA_QtQuickUseDefaultSizePolicy in qtbase Change-Id: I41d34682fed794cc3594f967b0e58892107b3a33 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Adapt layouts to take advantage of new size policy informationSanthosh Kumar2024-02-221-8/+18
| | | | | | | | | | | | | | The size policy been defined for QQuickItem and its subclasses (as part of task QTBUG-117597). This commit adds code so that Qt Quick Layouts will effectively use them. It also have an opt-out code path by testing for QGuiApplication::testAttribute(Qt::AA_QtQuickDontUseDefaultSizePolicy) Task-number: QTBUG-117597 Pick-to: 6.7 Change-Id: I624509a77a870d72a5c4ce96505516bf30801559 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Revert "Fix binding loop and polish issue in quick layout"Jani Heikkinen2024-01-121-1/+1
| | | | | | | | | | This reverts commit 9ad9d05f26184a79ad3fe09abdc662949088d19d. Reason for revert: QTBUG-120592 Change-Id: I6cba9e88832ac0d78280fd9d6f96b319748545be Pick-to: 6.7 6.6 6.5 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Revert "Remove dirty flag validation during geometry change in the layout"Jani Heikkinen2024-01-121-8/+2
| | | | | | | | | | This reverts commit d85de8da6011731e3ff31ae1361e71fecaedb0be. Reason for revert: QTBUG-120592 Pick-to: 6.7 6.6 6.5 Change-Id: I46f3b41508e9bfeca328b916ba172ea9e0d6aaa1 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Remove dirty flag validation during geometry change in the layoutSanthosh Kumar2024-01-101-2/+8
| | | | | | | | | | | | | | | The patch 9ad9d05f26184a79ad3fe09abdc662949088d19d adds validation to avoid rearrange in the layout as there is possibility to refer invalid QGridLayoutItem (particularly during item removal from the layout). The same can be fixed through m_disableRearrange flag which cause rearrange to happen in next polish (as with the earlier fix) instead of geometryChange(). Fixes: QTBUG-120592 Pick-to: 6.7 6.6 6.5 Change-Id: Ia17a41eeba46797631263d865de055b46e1208f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix binding loop and polish issue in quick layoutSanthosh Kumar2023-12-211-1/+1
| | | | | | | | | | | | | | | | | The quick layout item cause binding loop issue when layout item size were updated in-between polish. This has been fixed by not updating layout size hint during rearrange. But there is polish issue due to child item not being invalidated and this skips corresponding item box size calculation. This patch invalidate all the items in the rearrange list of the layout and finally, invalidate engine and layout. Fixes: QTBUG-117899 Fixes: QTBUG-118511 Pick-to: 6.7 6.6 6.5 Change-Id: I1e318335ce8b5268d878b48a02a089d703bb90ad Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QQuickLayout: improve polish loop warningMitch Curtis2023-06-051-1/+2
| | | | | | | | | | | | | - Print the layout that caused (or detected) the loop to make finding it easier. Until now it was only possible to find the item by debugging Qt, which is tedious for users. - Replace the module prefix ("Qt Quick Layouts") with a simpler "Layout" prefix, as qmlWarning(this) already ensures that the type name is printed at the beginning of the warning. Pick-to: 6.5 6.6 Change-Id: Ief801cad21958d7a8da406452f2918889f90658f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Expose isPropertySet of Layout attached dataMatthias Rauter2023-06-021-0/+4
| | | | | | | | | | | | The Layout attached data stores whether a property was set or not. This is useful to know from outside the Layout attached property and this patch exposes this information. It was not stored for two properties (alignment, margins), which is also added with this patch. This is also done in preparation for the LayoutProxyItem. Change-Id: Ia1ec33fa1f1f5836857ceba7999d7a0e750f1a66 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* doc: add both stretch factors to the list of attached propertiesOliver Eftevaag2023-05-161-0/+4
| | | | | | | | | | | | | The horizontalStretchFactor and verticalStretchFactor properties were both added in 6.5. Not only did we forget to mark them with a \since Qt 6.5, but we also forgot to add them to the list of attached properties that is mentioned on the RowLayout and ColumnLayout doc pages. Task-number: QTBUG-113230 Pick-to: 6.5 6.5.1 Change-Id: I8537fe5c9b5aa1389a8bfaf4e1abed3a1f0a34d5 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Carl-Lucien Armand Schwan <carl.schwan@kdab.com>
* Allow a layout with width or height == 0 to resize its child itemsJan Arve Sæther2023-05-111-1/+1
| | | | | | | Fixes: QTBUG-112740 Pick-to: 6.5 Change-Id: I66327f3fa76d3f1c14b62d0ac42d3fd4c28288b2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Add {horizontal,vertical}StretchFactorJan Arve Sæther2022-12-081-1/+73
| | | | | | | | | | | This utilizes the standard implementation of stretch factors that is already in the QGridLayoutEngine [ChangeLog][QtQuick][Layouts] Added support for stretch factors Fixes: QTBUG-32923 Change-Id: I4afa7636dda465af2230c2919daa5c40831c44ae Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Do not listen to baselineOffset changes unless really neededJan Arve Sæther2022-09-271-2/+14
| | | | | | | | | | | | | | | | | | | | | | For some controls, (e.g. TextInput and Text) we can get changes in baseline offset when they change their height. These changes will invalidate the layout and generate a polish event. This means that during a rearrange of a layout with TextInput children, it might change the height of its children. This might change the baselineOffset of these children, which again will cause the layout to have to be invalidated (and rearranged again) This double-loop is unnecessary if the layout is not supposed to align these items by their baselines, so we add some conditions to see if we really need to connect to the baselineOffsetChanged() signal. This also fixes a bug observed in the color dialog, where the semi-recursiveness described above lead to a problem with that the alpha TextField of the RGBA color input was *not* laid out by the parent RowLayout Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-105899 Change-Id: If66b4bbde6a37c962b157e166c883ba20ff24c21 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QuickLayouts: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102948 Change-Id: I0e84ea63b35892bdcbbaa9746936c82dc7e60607 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Improve layouts in terms of efficiency and stabilityJan Arve Sæther2022-04-081-47/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to this, properties reflecting size hints, such as implicitWidth, implicitHeight and Layout.minimumWidth etc are not immediately updated anymore, they are postponed until the next polish event. This avoids several recursion problems that Qt Quick Layouts suffered from. updatePolish() will now have the main responsibility to rebuild the layout recursively. This patch removes the call to ensureLayoutItemsUpdated() from several other places. ensureLayoutItemsUpdated() does the "rebuilding": 1. Ensure that all relevant items are populated in the internal layout engine. 2. query the size hints from the internal layout engine and apply those values to the different "implicit" layout properties, such as: (Layout.minimumWidth, implicitWidth, Layout.maximumWidth) This is done recursively, and done when the next updatePolish() arrives. After having removed several calls to ensureLayoutItemsUpdated(), this means that ensureLayoutItemsUpdated() is now only called from: - QQGLB::componentComplete() (initialization) - QQL::updatePolish() (rebuild after invalidation) - QQL::deactivateRecur() (teardown) This avoids many recursion problems we've experienced. In addition, I had to do other related fixes: * Make implicitWidth/implicitHeight act like a "true property" again: (i.e. do not emit implicitWidthChanged when fetching implicitWidth, this caused unexpected binding loop problems) Therefore, we remove the reimplementation of getImplicitWidth() and getImplicitHeight() * insertLayoutItems() will now insert zero-sized items (except those that are marked as transparentForPositioner). This is reflected by a simplification to shouldIgnoreItem(). The layout engine should take care of rows/columns of items with zero size regardless. Previously, when we checked if a child item should be included in a layout, we chose to ignore it if it had a max size of (0x0). However, this meant that we potentially had to rebuild a child layout (gathering all sizehints of the child layouts' children) just to check if it had a maximum size of (0x0). The problem was that in a layout hierarchy, layout items are added from top-to-bottom (it needs to know which items to include in the parent layout before continuing down the children of those same items). However, in order to know if a child layout should be included, it had to rebuild the child layout before it was ready, so there was a catch-22.... This worked before when the layout was built on-demand regardless, but with the approach this change does, shouldIgnoreItem() had to change. [ChangeLog][QtQuick][Layouts] Improved layouts in terms of efficiency and stability. Due to this, properties reflecting size hints, such as implicitWidth, implicitHeight and Layout.minimumWidth etc are not immediately updated anymore, they are postponed until the next polish event. Task-number: QTBUG-87250 Task-number: QTBUG-99103 Task-number: QTBUG-99104 Change-Id: I877287defed1ca0c9ecb88c83513da8f55cd6063 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Layouts: use qmlWarning for polish loopsMitch Curtis2021-12-171-1/+1
| | | | | | | | This shows the exact location of the affected layout. Pick-to: 6.2 6.3 Change-Id: I5343de642ecca00f2179269b6123da905a246b9c Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Doc: Make algorithm for distributing sizes in layouts more explicitKai Köhne2021-12-071-1/+5
| | | | | | | | Pick-to: 6.2 Fixes: QTBUG-98127 Change-Id: I1c27f03a6a61e8af12548ffaaeff5775476ed3c8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* Doc: Fix documentation issuesTopi Reinio2021-06-021-1/+1
| | | | | | | | | | * Comment out \instantiates referring to an internal class * Remove duplicate module page for Qt QML * Fix various linking problems Task-number: QTBUG-91875 Change-Id: I7675f8a253e0b0e0a031d8a3642b3d2786b75149 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Silence warnings about deprecated QString::QString(const char*)Friedemann Kleint2021-01-211-2/+2
| | | | | | | | | | | | Fix warnings like: src/qmllocalstorage/qqmllocalstorage.cpp:81:62: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] src/src/labs/settings/qqmlsettings.cpp:335:87: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] src/labs/settings/qqmlsettings.cpp:346:50: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or n1String [-Wdeprecated-declarations] src/labs/settings/qqmlsettings.cpp:361:50: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or n1String [-Wdeprecated-declarations] src/quicklayouts/qquicklayout.cpp:1241:61: warning: QString::QString(const char*) is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] Change-Id: I87d7e28842a4f7f75b02c1e78eb3df400adcab94 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Quick.Layouts: Make plugin optionalFabian Kosmale2021-01-181-0/+1308
This moves the Layouts types into a new library and is meant to make them availabe to the QML compiler at some point in the future. Change-Id: I9b2b31a78b0e9ca8b6c0db1fc9272d9941c61814 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>