How can we trasfer widget focus to next widget by pressing tab key?
-
http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#setTabOrder
According to the Doc :
@ // WRONG
setTabOrder(c, d); // c to d
setTabOrder(a, b); // a to b AND c to d
setTabOrder(b, c); // a to b to c, but not c to d
@Check your codes
-
[quote author="Rahul Das" date="1324882460"]http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#setTabOrder
According to the Doc :
@ // WRONG
setTabOrder(c, d); // c to d
setTabOrder(a, b); // a to b AND c to d
setTabOrder(b, c); // a to b to c, but not c to d
@Check your codes[/quote]
I have tried something like this but not getting focus
@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
QRadioButton *radio1 = new QRadioButton("radiobutton1",&w);
radio1->setGeometry (150,20,100,40);
QRadioButton *radio2 = new QRadioButton("radiobutton2",&w);
radio2->setGeometry (200,50,100,40);
QRadioButton *radio3 = new QRadioButton("radiobuton3",&w);
radio3->setGeometry (240,80,100,40);
QWidget::setTabOrder (radio1,radio2);
QWidget::setTabOrder (radio2,radio3);
w.show();
return a.exec();
}
@ -
[quote author="Rahul Das" date="1324886219"]Just remembered... Here the problem must be autoExclussive property.
Just set it false :
@
radio1->setAutoExclusive(0);
radio2->setAutoExclusive(0);
radio3->setAutoExclusive(0);@Let me know the result.[/quote]
Thanks, now it is working but i have one more doubt here suppose i have custom widget there how i can show visually that the focus is in that widget.
-
There could be many ways. If your custom widget contain radio,lineedit etc, and you want to focus one emong them, you may use QWidget::setFocusProxy.
Or if any visual changes in appearance is needed on focus, you can reimplement QWidget::focusInEvent and set some styles.
You can use event filters also.
-
The style in charge usually handles this. The widget having the focus is most often displayed differently. If not, then this is the usual behavior of that style and you should mess with that only for very good reasons - which most developers do not have, to be honest.