How to disable Second QComboBox by clicking on the first QComboBox?
-
wrote on 8 Jan 2022, 15:50 last edited by
-
Hi,
What is the goal of that behaviour ?
-
wrote on 8 Jan 2022, 23:04 last edited by
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...
-
wrote on 9 Jan 2022, 05:14 last edited by
@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 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.wrote on 9 Jan 2022, 06:11 last edited by@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? -
@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?wrote on 9 Jan 2022, 06:44 last edited by HeerokNewbie 1 Sept 2022, 06:49@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.
-
@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.
wrote on 9 Jan 2022, 08:04 last edited by@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?
-
@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?
wrote on 9 Jan 2022, 08:25 last edited by@JonB Yes ! and my problem is solved thank you @posktomten
1/8