braindead
3rd September 2013, 10:18
Hello,
i stumbled on a problem using QButtonGroups. As far as I understand QButtonGroup logically organises AbstractButtons. A TAB would navigate on the group and the next TAB navigate away from the group. Within the group the AbstractButtons are navigated with the arrow keys. This all works fine with QRadioButtons. I need the same concept but with QCheckBoxes...but as soon as my ButtonGroup consists of CheckBoxes the arrow key navigation does't work any more (TAB navigation is as aspected). I also checked for checkable QPushButton - same problem here. For CheckBox and PushButton it is practically not possible to navigate through the Buttons of the group anymore (apart from the mouse).
Please consider the following code, change BUTTON_TYPE as neccessary:
#include <QApplication>
#include <QtGui>
#define BUTTON_TYPE 0
int main(int argc, char **args)
{
QApplication dialog(argc, args);
QWidget window;
QButtonGroup* bg = new QButtonGroup(&window);
QAbstractButton* cb1;
QAbstractButton* cb2;
QAbstractButton* cb3;
switch(BUTTON_TYPE)
{
case 0:
cb1 = new QCheckBox("cb1", &window);
cb2 = new QCheckBox("cb2", &window);
cb3 = new QCheckBox("cb3", &window);
break;
case 1:
cb1 = new QPushButton("cb1", &window);
cb2 = new QPushButton("cb2", &window);
cb3 = new QPushButton("cb3", &window);
cb1->setCheckable(true);
cb2->setCheckable(true);
cb3->setCheckable(true);
break;
default:
cb1 = new QRadioButton("cb1", &window);
cb2 = new QRadioButton("cb2", &window);
cb3 = new QRadioButton("cb3", &window);
break;
}
bg->addButton(cb1);
bg->addButton(cb2);
bg->addButton(cb3);
QLayout *layout = new QVBoxLayout;
layout->addWidget(cb1);
layout->addWidget(cb2);
layout->addWidget(cb3);
window.setLayout(layout);
window.show();
return dialog.exec();
}
I also flew over the Qt sourcecode (QAbstractButton::moveFocus), but on the rush I couldn't find any reason why it shouldn't work for the other two Button types (PushButton and Checkbox).
Did I forget something or is there any misconception on my behalf? Anybody else noticed this problem?
Hope you can enlighten me.
Regards
i stumbled on a problem using QButtonGroups. As far as I understand QButtonGroup logically organises AbstractButtons. A TAB would navigate on the group and the next TAB navigate away from the group. Within the group the AbstractButtons are navigated with the arrow keys. This all works fine with QRadioButtons. I need the same concept but with QCheckBoxes...but as soon as my ButtonGroup consists of CheckBoxes the arrow key navigation does't work any more (TAB navigation is as aspected). I also checked for checkable QPushButton - same problem here. For CheckBox and PushButton it is practically not possible to navigate through the Buttons of the group anymore (apart from the mouse).
Please consider the following code, change BUTTON_TYPE as neccessary:
#include <QApplication>
#include <QtGui>
#define BUTTON_TYPE 0
int main(int argc, char **args)
{
QApplication dialog(argc, args);
QWidget window;
QButtonGroup* bg = new QButtonGroup(&window);
QAbstractButton* cb1;
QAbstractButton* cb2;
QAbstractButton* cb3;
switch(BUTTON_TYPE)
{
case 0:
cb1 = new QCheckBox("cb1", &window);
cb2 = new QCheckBox("cb2", &window);
cb3 = new QCheckBox("cb3", &window);
break;
case 1:
cb1 = new QPushButton("cb1", &window);
cb2 = new QPushButton("cb2", &window);
cb3 = new QPushButton("cb3", &window);
cb1->setCheckable(true);
cb2->setCheckable(true);
cb3->setCheckable(true);
break;
default:
cb1 = new QRadioButton("cb1", &window);
cb2 = new QRadioButton("cb2", &window);
cb3 = new QRadioButton("cb3", &window);
break;
}
bg->addButton(cb1);
bg->addButton(cb2);
bg->addButton(cb3);
QLayout *layout = new QVBoxLayout;
layout->addWidget(cb1);
layout->addWidget(cb2);
layout->addWidget(cb3);
window.setLayout(layout);
window.show();
return dialog.exec();
}
I also flew over the Qt sourcecode (QAbstractButton::moveFocus), but on the rush I couldn't find any reason why it shouldn't work for the other two Button types (PushButton and Checkbox).
Did I forget something or is there any misconception on my behalf? Anybody else noticed this problem?
Hope you can enlighten me.
Regards