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

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




      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"));


      • 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.


        Issue Links

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



              Unassigned Unassigned
              toralf.lund@pgs.com Toralf Lund
              0 Vote for this issue
              2 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes