TabOrder for QToolButton not working
Hi,
I am using Qt 4.4.3.
I have a dialog comprising of QPushButtons (For OK and Cancel) and 2 QToolButtons on the dialog neat the QPushButtons.
Though I have set the tabfocus to 'StrongFocus' and explicitly set the tab order, the QToolButtons don't get tab focus at all. Even in the QTDesigner preview, I see focus going between the QPushButton's OK and Cancel, and the subsequent two clicks on the tab button don't do any thing and then on the third tab click, focus comes back to the QPushButton.
I tried explicitly defining it as follows:
Code:
:
:
:
// Setting focus
buttonStart->setFocusPolicy(Qt::StrongFocus);
buttonStop->setFocusPolicy(Qt::StrongFocus);
// Setting tab order
setTabOrder(buttonOK, buttonCancel);
setTabOrder(buttonCancel, buttonStart);
setTabOrder(buttonStart, buttonStop);
// Where buttonOK and buttonCancel are QPushButtons
Help in this matter will be appreciated.
Thanks.
Re: TabOrder for QToolButton not working
How do you know the two tabs don't do anything? Maybe QToolButton doesn't provide a visual hint that it has focus?
Re: TabOrder for QToolButton not working
Yes, there is no visual hint that the two QToolButton's get focus. But while tabbing, the visual hint and focus remains on the OK button.
Pressing enter at any time, results in the OK button (which has the visual highlight), being pressed.
Can a QToolButton get tab focus?
Re: TabOrder for QToolButton not working
Could someone please suggest how to bring a visual hint (border around the button) for a QToolButton, when using the tab key to access the buttons in a dialog.
Also, on MAC how do make the tab/shift-tab work 'a la Windows'?
Appreciate any pointers in the right direction.
Thanks!
Re: TabOrder for QToolButton not working
Quote:
Originally Posted by
gren15
Could someone please suggest how to bring a visual hint (border around the button) for a QToolButton, when using the tab key to access the buttons in a dialog.
You can use another button class instead of QToolButton. Tool buttons act the way they act. If you want something else you have to provide it yourself. Use a QPushButton or provide your own subclass of QAbstractButton or QToolButton.
Re: TabOrder for QToolButton not working
Thanks wysota for confirming the behaviour.
Regarding the MAC issue. I use the same .ui file for both Windows and MAC, but the Shift+Tab/ Tab doesn't work on MAC. Does it have to be programmed differently for MAC?
Please suggest.
Thanks once again for your time.
Re: TabOrder for QToolButton not working
I don't know how focus changes work on Mac, so it's hard for me to suggest anything but I suspect Qt follows the platform guidelines and if that doesn't work you shouldn't try to force a different behaviour or your users might complain. Some things may be overridden using QStyle::styleHint() but I would really think twice before forcing something fundamental.