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

ListView's forceLayout() doesn't work as intended

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.2, 6.9.0 Beta2
    • Quick: Layouts
    • None
    • OS: macOS Sequoia 15.3, Windows 11 24H2, Linux X11 desktop (deepin 25 was used)
      Qt: 6.8.2
    • All

    Description

      The attached minimal example contains a horizontal list view, which will contain many red rectangle. The intended behavior is to make all the red rectangle visible at the same time in the view. The delegate's width is thus bound to (listview.width / model.count) so all items can be shown.

      Step to reproduce:

      1. Open the QML file provided below (relayout.qml), don't resize the window
      2. Click "Add Item" button for 4 times
      3. The last added red rectangle will be placed outside the green list view area
      4. Click "Force Layout"
      5. The last added red rectangle will still at the same location, which is outside the green list view area (the bug)
      6. Drag the window right border and resize the window for a little bit, you'll see the newly added rectangle now placed at the right position.

      Step 3 is probably another bug because if we turn the animation off, the position of the newly added rectangle will be correct and we will then no longer need to do any force relayout.

      After step 5, we can keep press "Add Item" too check the behavior, all newly added items will be at the wrong location, and "Force Layout" button will always not able to correct the position issue.

      A screen record is also attached to showcase the issue.

      Attachments

        1. relayout.qml
          2 kB
          Gary Wang
        2. 录屏2025-02-20 21.31.21.mov
          725 kB
          Gary Wang
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            blumia Gary Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes