3

I have a problem with QComboBox like this: I have a QComboBox for configuring color, I use QColorDialog in QComboBox. In display mode, I just want to display value of QComboBox for user, user cannot edit value or select other value from QComboBox. I tried 2 solutions like this:

  • use set property editable = false: user still chooses other value by selecting combobox
  • use set property enable = false: user cannot edit or select, but color in combobox is grey, not value that I configured, ex: red.

I googled but don't grab any answers. Somebody helps me?

m7913d
  • 10,244
  • 7
  • 28
  • 56
  • Please provide a [mcve]. What do you mean by `QColorDialog` in `QComboBox`? You may want to specify the [color when disabled using qss](https://stackoverflow.com/questions/25139616/how-to-set-a-different-background-color-to-a-disabled-button-with-qss). – m7913d Jun 18 '17 at 20:10
  • Could you clarify with an screenshot how it looks? Is the QColorDialog an option in your QComboBox, next to other items? – RvdK Jun 18 '17 at 20:17

1 Answers1

1

You could disallow changes by creating a slot for currentIndexChanged:

enter image description here

and changing it back.

automorphic
  • 680
  • 7
  • 18