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

Let the style provide a custom base font and palette for a widget

    XMLWordPrintable

Details

    Description

      Styles that need special fonts for special widgets have two options today:

      1) Calling QApplication::setFont(const QFont &font, const char *className)
      2) Calling QWidget::setFont() in QStyle::polish(QWidget *)

      The problem with #1 is that this applies to the entire application even if the application uses several styles (Designer's preview form, as one example).

      The problem with #2 is that it overrides the application and user font settings.

      Proposal: Add a protected "QStyle::setFont(const QFont *font, const char *className)" and a public getter "QFont QStyle::font(QWidget *widget) const" that QApplication::font() calls, and the resulting font is resolved against the app font. That way the style can set per-widget fonts (and palettes too!) without disrupting font and palette propagation.

      Ideally (Qt 5?) QStyle would have two virtual functions for this instead of a protected setter. And QStyle::polish(QPalette&) would be replaced by the same approach.

      Use case: Windows Mobile Style (CE) and QGtkStyle.

      Note: Sometimes even more context is needed (than classname) - e.g., for CSS the dependency graph is quite complex so this function would have to be called for each QWidget::paintEvent() / initStyleOption.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes