Results 1 to 7 of 7

Thread: TabOrder for QToolButton not working

  1. #1
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default 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:

    Qt Code:
    1. QToolButton *buttonStart;
    2. QToolButton *buttonStop;
    3. :
    4. :
    5. :
    6. // Setting focus
    7. buttonStart->setFocusPolicy(Qt::StrongFocus);
    8. buttonStop->setFocusPolicy(Qt::StrongFocus);
    9.  
    10. // Setting tab order
    11. setTabOrder(buttonOK, buttonCancel);
    12. setTabOrder(buttonCancel, buttonStart);
    13. setTabOrder(buttonStart, buttonStop);
    14.  
    15. // Where buttonOK and buttonCancel are QPushButtons
    To copy to clipboard, switch view to plain text mode 

    Help in this matter will be appreciated.
    Thanks.
    Last edited by gren15; 22nd May 2009 at 18:25.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default 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?

  4. #4
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default 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!

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: TabOrder for QToolButton not working

    Quote Originally Posted by gren15 View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default 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.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt+QWebKit+Java+Flash not working
    By progDes in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2009, 16:49
  2. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  3. QDevelop and CTags -> Not working
    By philwinder in forum Qt-based Software
    Replies: 13
    Last Post: 9th May 2008, 21:40
  4. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2007, 23:14
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.