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

Qt Stylesheet Qt6 refactoring

    XMLWordPrintable

Details

    Description

      Since I'm not going to QtCS, here's a draft of some sort of plan we've been discussing here and there.

      Problems with style sheets

      A) People using stylesheets for complex things, completing 95% then realizing it's not possible to complete.

      B) Performance problems with big QWidget hierarchies that have frequent reparenting (due to rule reloading)

      C) Ugly code (special code paths) in QWidget::setStyle() & friends to accommodate style sheets. Hard to maintain too.

      D) Stylesheets not mixing well with QProxyStyles

      E) You can't have two dialogs with different global stylesheet.

      Solutions

      From talking to several developers, the solutions range from "document the limitations" to "depracate stylesheets".

      I propose factoring it out from QtWidgets and moving it to qtstyleplugins.git (which is also orthogonal to deprecation/documentation)

      Tasks

      1. Decouple style sheets from QWidgets
      1.1 Remove the setStyleSheet() methods
      1.2 Allow QStyles to be propagated to children (required by stylesheets, but useful for other purposes!)

      2. Make QStyleSheetStyle public and move it to qtstyleplugins.git

      3. Make QStyleSheetStyle behave like a regular proxy style, allowing it to be chained however we like

      4. Make the global sheet just a property of QStyleSheetStyle, so you can have completely different sheets for different dialogs

      Conclusion

      With this I think we don't need to explicitly deprecate. With the setStyleSheet() methods gone and any trace of sheets moved to
      qtstyleplugins.git new users won't pick stylesheets as their first choice, as they'd have to jump some hoops to do so.

      Legacy apps which can't afford a rewrite will still be able to use style sheets.

      And finally, fixing D and E for legacy apps would be trivial (These are requests seen from customers from time to time, they're apps are too big to port to QStyle now).

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              iamsergio Sergio Martins
              Votes:
              6 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes