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

ComboBox does not notify its lineEdit about font change after stylesheet removal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 5.6.1
    • Widgets: Style Sheets
    • None

    Description

      Setting a stylesheet on a window (e.g. with font-size only) correctly changes the style of all its widgets. Unsetting it by setting an empty stylesheet, however, changes the style of all widgets except editable comboboxes (tested with spinboxes, lineedits and other widgets).

      QComboBox creates a lineEdit when the editable flag is set to true and deletes it when it is set to false. When a FontChange event is caught (in QComboBox::changeEvent(QEvent *e)), the combobox notifies the viewContainer about the change but not the lineEdit, which is not part of it.

      I attach a patch that solves the issue for me. However, I am not sure it is a complete fix. I logged all the events and apparently a DynamicPropertyChange and a FontChange events are triggered for the main window and propagated to all widgets when the stylesheet is set, but none of them is triggered when the stylesheet is unset. With the patch, a FontChange is propagated upon the stylesheet removal, but no DynamicPropertyChange yet. Is this by design or is the fix missing something?

      There is another small problem: unsetting the stylesheet with a null string causes other widget to behave bad, while using a single-space string leads problems only with the QComboBox. We'll investigate this further and possibly open a different ticket, but it might be related to this (another related: QTBUG-33537).

      UPDATE:

      There is not only the font change problem, changing the stylesheet at runtime seems to break multiple things. Including, but not exclusively:

      • Changing the "editable" property at runtime makes the font wrong again (a new `lineEdit` is created and not notified about any style change?)
      • Setting the stylesheet to a single space makes the items in the list overlap, while the height of the list is correct
      • While the patch fixes the issue on Mac, the appearance is still sometimes wrong on Windows (could not isolate the differences yet)
      • ...

      It looks like the whole component was not thought for a runtime style change, a small patch could be not enough.

      Attachments

        Issue Links

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

          Activity

            People

              mmutz Marc Mutz
              narcolessico Eugenio Rustico
              Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes