how to make a combo box read only
-
I am developing and application in which when you select some item in combo box and after selection if you press a button present in the gui . Then the combo box selection should not me changed till i perform some operation and after i perform the operation the combo box should be enabled for editing or for selection of item . How can we do this ?
-
What's wrong taking a short look into the documentation and find setEnabled()?
https://doc.qt.io/qt-5/qcombobox-members.html -
I am developing and application in which when you select some item in combo box and after selection if you press a button present in the gui . Then the combo box selection should not me changed till i perform some operation and after i perform the operation the combo box should be enabled for editing or for selection of item . How can we do this ?
@ManiRon
AnyQWidgetcan be disabled via https://doc.qt.io/Qt-5/qwidget.html#setDisabled / https://doc.qt.io/Qt-5/qwidget.html#enabled-prop. You can use that to achieve what you want. -
@JonB has half of it. If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.
Hi,
@KevDev said in how to make a combo box read only:
If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.
How is that related to the question at hand ?
-
Hi,
@KevDev said in how to make a combo box read only:
If you then set the foreground color via the style sheet to black (or any other color of your choosing), it looks like it should, and you can't change it.
How is that related to the question at hand ?
-
@SGaist
Hi
Its to avoid the faded text effect
when set to disabled which makes it hard to read on some platforms
versus
(setting color in style sheet) -
Ha ! I misunderstood that part.
That's usually a bad idea to keep things as normal when disabled.
@SGaist
Yep, i only guessed as i had some bug reports from user complaining it was hard to read :)Totally agree as it violates the visual clues for being Disabled but can be used to adjust the contrast
to the background as it can be hard to read on some system where they did alter the screen settings for contrast etc. -
Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented
@stokito said in how to make a combo box read only:
Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented
Hi,
What would read-only mean ? The user cannot interact with the widget ? Then setEnabled/setDisabled are already there.
There's no need for a modified property. QComboBox already provides APIs that signals a change happened. -
Are any plans to implement the ReadOnly for the QComboBox? Similarly the Modified property also needs to be implemented
@stokito
As @SGaist says. What does "ReadOnly" here mean to you, and what is "Modified" about?
For read-only, do you perchance mean setEditable(false)? That is for the user to be able edit/insert items into the combobox choices. But that is the default anyway.