If I have buttonGroup and several radio buttons, I can set focus only to first element of radioGroup, using tab.
How to do that If i press tab, focus set to next element?
If I have buttonGroup and several radio buttons, I can set focus only to first element of radioGroup, using tab.
How to do that If i press tab, focus set to next element?
I also have made this:
void Widget::keyPressEvent(QKeyEvent *keyEvent)
{
if (keyEvent->key() == Qt::Key_Tab {
focusNextChild();
keyEvent->accept();
}
}
but this does not help me
zoz (30th May 2010)
zoz (30th May 2010)
No, it does not help..
I have tryed this thing
It's an unresolved but/request.
http://bugreports.qt.nokia.com/browse/QTBUG-131
Use the arrow keys.
Or as an alternative, provide your own button group.
can i inherit from QButtonGroup and setTabOrder?
I need do it, because I have widget with ButtonGroup, that consists of 5 QPushButtons with setCheckable (true);
Suggestion:
Set auto exclusive to false on all your buttons.
Then, when you check a button, also look at the checkstate of the other 4 buttons and set them to not checked.
This is a bit of ugly work, but then you'll get the tabs to work.
Edit: the above description is what I actually meant with your own button group.
The use of tabs to set the focus to the next button is disabled at the button level itself when using auto exclusive
Thanks! !
Hm.. it is not working!
I write some app which show, that we can't using tab for move focus
code Code:
#include <QtGui> class Widget : public QWidget { public: Widget() { buttons = new QPushButton[5]; QButtonGroup *buttonGroup = new QButtonGroup; QVBoxLayout *buttonsLayout = new QVBoxLayout; buttonGroup->setExclusive(false); for (int i = 0; i < 5; i++) { buttons[i].setAutoExclusive(false); buttons[i].setCheckable(true); buttonGroup->addButton(&buttons[i]); buttonsLayout->addWidget(&buttons[i]); buttons[i].setText("button#" + QString().setNum(i)); } QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); setFixedSize(sizeHint()); }; private: QPushButton *buttons; }; int main(int argc, char **argv) { QApplication app(argc, argv); Widget *widget = new Widget; widget->show(); return app.exec(); };To copy to clipboard, switch view to plain text mode
Any ideas?
I'll write you something, will take an hour or two. I'll need to finish something else first.
Ok I am waiting
somename (30th May 2010)
Thank you very much!
Bookmarks