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

QLabel Style Not Applied When Placed in Grid Layout Inside QScrollArea

XMLWordPrintable

    • Windows

      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.

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

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

              Created:
              Updated:

                There are no open Gerrit changes