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

No way to change text colour in combobox button when using the GTK+ style

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 4.5.3, 4.7.1, 4.7.2, 4.7.3, 5.1.1, 5.3.1
    • Fix Version/s: None
    • Environment:
      CentOS release 5.7
      Ubuntu Linux

      Description

      There appears to be no way to change the text colour of a "closed", non-editable QComboBox, which is represented by a button, when using the GTK+ GUI Style. In particular, the following have no effect:

      QComboBox *combo=new QComboBox;
      ...
      combo->setStyleSheet("color: red");

      ...
      QPalette palette;

      palette.setColor(QPalette::ButtonText, QColor("blue"));
      palette.setColor(QPalette::WindowText, QColor("blue"));

      combo->setPalette(palette);

      • the button text is still black after this. Or, I suppose more generally, the colour of the active Gtk theme. After setting the stylesheet, the colour of entries in the combo's popup menu does change, but again, the button is unaffected. I've tested the setStyleSheet() and setPalette() methods independently, of course.

      If the editable property is set to true, so that the combobox is drawn as a "text entry" instead of a button, the colour changes as expected. It also does if switching to a different global style via Qt Configuration. Unfortunately, GTK+ is the default on typical setups where our software is installed, and forcing users to change this does not seem right.

      This is also not a limitation for buttons in general, i.e. stylesheet or palette colours will indeed be used for a normal QPushButton.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              toralf.lund@pgs.com Toralf Lund
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes