How to select multiple checkboxes
-
wrote on 18 Sept 2024, 14:09 last edited by
I have checkboxes stacked together
checkbox_1
...
checkbox_9
I want to be able to select some with something like this
click to checkbox_1
press shift
click to checkbox_9all checkboxes selected
-
You have to implement such a logic by yourself.
-
wrote on 18 Sept 2024, 15:05 last edited by
you mean third party lib like libevdev?
-
you mean third party lib like libevdev?
@JacobNovitsky said in How to select multiple checkboxes:
you mean third party lib like libevdev?
I don't see why you would need this for such a simple task - but do what you want.
-
wrote on 18 Sept 2024, 15:07 last edited by
For sure I would use any another more simple variant
what is your suggestion? -
For sure I would use any another more simple variant
what is your suggestion?@JacobNovitsky said in How to select multiple checkboxes:
what is your suggestion?
For what? Checking if a key is pressed?
-
wrote on 18 Sept 2024, 15:33 last edited by
No, I need to select 10 check boxes with one click using SHIFT
-
wrote on 18 Sept 2024, 15:55 last edited by VRonin
It's FAR from perfect but should be something like this
private: int lastPressedCBox = -1; QList<QCheckBox*> checkBoxesContainer;
for(int i=0;i<checkBoxesContainer.size();++i) QObject::connect(checkBoxesContainer.at(i), QCheckBox::clicked,[i,this](){ if(lastPressedCBox>=0 && QGuiApplication::queryKeyboardModifiers() & Qt::ShiftModifier){ for(j=std::min(i,lastPressedCBox);j<=std::max(i,lastPressedCBox);++j) checkBoxesContainer.at(j)->setCheckState(checkBoxesContainer.at(std::min(i,lastPressedCBox)).checkState()); } lastPressedCBox=i; });
1/8