Dynamically hide check next to QCheckBox widget?
-
Is there a way to dynamically hide the check portion of a QCheckBox widget so that it just looks like a regular QLabel? I have a dialog where I have a list of options. Depending on the state of other options in the dialog some options become optional. When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked. When the same item becomes required I'd like to hide the check mark so it just looks like a plain label and always enable the buddy control.
If I have to subclass the control and override the paint function that's fine, but can you offer some pointers on how exactly to do that? (I'm still somewhat new to Qt)
-
@Dan203 said in Dynamically hide check next to QCheckBox widget?:
When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked.
I do not understand. How is the checkbox going to become checked if it is not visible to check?
-
@ChrisW67 said in Dynamically hide check next to QCheckBox widget?:
@Dan203 said in Dynamically hide check next to QCheckBox widget?:
When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked.
I do not understand. How is the checkbox going to become checked if it is not visible to check?
So when the option is required the check will be hidden and the checked state will only be controllable via code. When the option is optional the check will be shown and the user will be able to check/uncheck.
I'm trying to create something similar to the attached, but without the property list control. Just using regular dialog controls.
See how the checked items are enabled and the unchecked ones are disabled? Except in some circumstances I need to be able to dynamically switch that check off and control the enabled/disabled state only via code.
-
@Dan203 said in Dynamically hide check next to QCheckBox widget?:
I guess another option is a I could use a check without any text and just place it next to a regular QLabel. Then just show/hide the check as needed. I just tried it briefly in designer and that does work.
Actually I was just playing with this option and it works exactly like I want. And it's easy to do via simple signals/slots. So I'm just going to go this route.