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

QLabel Style Not Applied When Placed in Grid Layout Inside QScrollArea

    XMLWordPrintable

Details

    • Windows

    Description

      When placing QLabel widgets inside a QGridLayout within a QScrollArea, the applied stylesheet does not take effect. However, the same QLabel style works correctly when the label is placed outside the scroll area.

      Steps to Reproduce:

      1. Build and run the attached example project.
      1. Observe that the QLabel widgets inside the QScrollArea do not apply the expected style (e.g., background color).
      1. Compare with a similar QLabel placed outside the scroll area that does apply the style correctly.

      Expected Behavior:
      All QLabel widgets, whether inside or outside a QScrollArea, should apply the stylesheet consistently.

      Actual Behavior:
      Labels inside the scroll area do not reflect the applied style, unlike those outside.

      Workaround:
      The only way to force the style to apply inside the scroll area is to:

      • Not set a parent on the QLabel
      • Set the Qt::Window flag on the label

      This workaround is not ideal and breaks normal widget hierarchy and layout.

      Attachments

        1. QTBUG-137551.zip
          19 kB
        2. qtbug137551.zip
          2 kB
        3. QLabel style issue.png
          QLabel style issue.png
          78 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            chakib Chakib Boutaghane
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes