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

QLayout::replaceWidget removes the to widget from layout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0 RC
    • 5.2.1
    • Widgets: Layout
    • None
    • d59638f21d7ea7c2a7f5c57b3eca27da984a1917

    Description

      If a widget has the Qt::WA_LaidOut attribute set and it is to add in the layout with replaceWidget it is first added in QLayoutPrivate::replaceAt and then removed in QLayout::addChildWidget.

      In the attached files: Everytime the button is clicked it swaps the two labels. If NORMAL is defined only the first time each label is inserted into the layout they are laid out. If NORMAL is not defined they are laid out everytime.

      I see two ways to solve the problem:

      1. Replace
        qlayout.cpp line 877
        if (l && removeWidgetRecursively(l, w))

        with

        if (l && l != this && removeWidgetRecursively(l, w))
      2. Unset the attribute (as seen in the attached files if the define is commented out).

      Attachments

        1. 37724.tar.gz
          0.9 kB
        2. main.cpp
          0.2 kB
        3. test.pro
          0.1 kB
        4. widget.cpp
          1 kB
        5. widget.hpp
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            smd Jan Arve
            hazardy Björn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes