How to disable Second QComboBox by clicking on the first QComboBox?
-
I have two ComboBox. I want to disable second ComboBox when i click (Mouse Click) on first comboBox and same operation for other combobox. So is it possible? If yes so how ? Please check the images for better explanation.
-
Hi,
What is the goal of that behaviour ?
-
Hi!
connect(ui->comboOne, QOverload<int>::of(&QComboBox::activated), [ = ]() { ui->comboTwo->setDisabled(true); }); connect(ui->comboTwo, QOverload<int>::of(&QComboBox::activated), [ = ]() { ui->comboOne->setDisabled(true); });
There may be a need for a way to reenable them again...
-
@SGaist I don't understand What is "goal of the behaviour" ? 😥
I have already given as much information as I know.
I want the second one combobox to be disabled automatically when I click on the first one combobox. Combobox does not have (isfocus()) function. -
@SGaist asked WHY you want to do that...
This is very weird UX design... maybe there are other ways.
What do you what to achieve in total? -
@Pl45m4 @SGaist I am making a software. In which there are two comboboxes and one pushbutton. And each combobox stores different file names of the user. So I want the function to first check which combobox is active whenever I click on pushbutton. And for this I have to disable one of the combobox first. and access the items of whichever combobox is active. The combobox also doesn't have isFocused() function so that I can check which combobox is active. Please tell me which function and class I have to use that whenever the user clicks on one of the comboboxes, that combobox becomes active and the other disabled.
-
@HeerokNewbie said in How to disable Second QComboBox by clicking on the first QComboBox?:
there are two comboboxes and one pushbutton
So I want the function to first check which combobox is active whenever I click on pushbutton.If you wait for a click on a
QPushButton
(not shown in your picture), how will any of the comboboxes have focus at that time --- won't focus move to the pushbutton?Meanwhile did you try @posktomten's code above? Did that do what you want?
-
@JonB Yes ! and my problem is solved thank you @posktomten