[Qt-interest] is this expected behaviour.

Pritam Ghanghas pritam_ghanghas at infosys.com
Fri Jul 16 15:37:41 CEST 2010


Hi

I was trying to put a few pushbuttons in a layout and inside a
QButtonGroup also. 
When I put the checkable buttons inside the QButtonGroup, tab or arrow
key focus navigation stops working. It works fine if the buttons are not
checkable or the I dont use the buttongroup. 
Now the situation is either I will have a put something in keypressEvent
for navigation or handle "exclusive selection" myself.

Here is a sample of code that reproduces the problem. Though I can take
other approaches but shouldnt it work out of the box.

#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
QHBoxLayout layout;
w.setLayout(&layout);
QButtonGroup buttonGroup;
for (int i = 0 ; i < 4; i++)
{
   QPushButton *button = new QPushButton(QString::number(i));
   button->setCheckable(true); // comment this and it will work
   layout.addWidget(button);
   buttonGroup.addButton(button); // or comment this, it will work
}
w.show();
a.exec();
}
 




More information about the Qt-interest-old mailing list