Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move only-one-active-toggle-feature from ofxGuiGroup to ofxToggle #16

Open
frauzufall opened this issue Jul 23, 2015 · 5 comments
Open

Comments

@frauzufall
Copy link
Owner

as described in http://forum.openframeworks.cc/t/extending-ofxgui-with-new-widgets/16670/11?u=frauzufall

@frauzufall
Copy link
Owner Author

@martialgallorini I am looking into the setExclusive feature of toggles in QT - I only find this: http://doc.qt.io/qt-4.8/qbuttongroup.html There the attribute is also applied to the group. Am I missing something or do you have another reference for me? Thank you!

@martialgallorini
Copy link

Hello @frauzufall ,

You can make all buttons checkable (to set them active or not) and make them auto exclusives. On a layout if you set all buttons auto exclusive, there will be only one button active at the same time for all buttons. If you need multiple groups of auto exclusive buttons, you can put them in a button group. More generally you can put them in different widgets (not only button groups) as the auto exclusive property action is relative to the parent widget. Say if you have 8 buttons and 4 in 2 different groups, all auto exclusive, you can have 2 buttons checked at the same time, eg. one in each group.

Example code :

// create a group
QButtonGroup* group = new QButtonGroup(this);

// create buttons
button1 = new QPushButton("Button 1", this);
button2 = new QPushButton("Button 2", this);
button3 = new QPushButton("Button 3", this);

// add buttons to group
group->addButton(button1);
group->addButton(button2);
group->addButton(button3);

// set buttons checkable and mutually exclusive
button1->setCheckable(true);
button1->setAutoExclusive(true);

button2->setCheckable(true);
button2->setAutoExclusive(true);

button3->setCheckable(true);
button3->setAutoExclusive(true);

Groups are from QButtonGroup class : http://doc.qt.io/qt-5/qbuttongroup.html

Buttons are QPushButton class objects, and some of the button properties, like "exclusive", are held by the base QAbstractButton class : http://doc.qt.io/qt-5/qabstractbutton.html

hope this helps

@BenBergman
Copy link

Was there every any progress on this? I could really use some sort of radio button or drop down in my current project.

@frauzufall
Copy link
Owner Author

Hey Ben, you can already use radio toggles! Just add the toggles to a group or panel and call group->setExclusiveToggles(true);

@frauzufall
Copy link
Owner Author

This issue is just about the way to implement that feature which I wanted to change once, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants