Results 1 to 6 of 6

Thread: Tab navigation and QListWidget

  1. #1
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Tab navigation and QListWidget

    Hello,

    I have this fantastic Dialog, Qt::StrongFocus, with 2 buttons (Qt::StrongFocus) and a QListWidget (Qt::StrongFocus) and TabKeyNavigation = true...

    When I tab through the Dialog and QListWidget gets the focus, it will select the next item in the list when I press Tab again...It should step out and select the next widget...

    What am I doing wrong?

    Arthur

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Tab navigation and QListWidget

    You can disable tab key navigation on the view.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Leiden, the Netherlands
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Tab navigation and QListWidget

    Thank you for your answer. However turning off tabnavigation results in the fact that I cannot set the focus on my list using the tab key.

    I want:
    Focus in by tab
    Focus out by tab
    Change selection using arrow keys.

    Just like every regular windows app. I don't know how to configure my list so that it behaves like that...

  4. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Thanks
    3
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tab navigation and QListWidget

    Strange, when I disable tab key in my app, I get this focus on the first item (not the blue rubberband, but the selection rect). When I tab again, the focus goes on the following widget.

    Moreover, to change selection with arrow keys, I think it's enabled by default...

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Tab navigation and QListWidget

    Arthur, have you reimplemented any event handlers?
    J-P Nurmi

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Tab navigation and QListWidget

    Here's an example which works fine for me with Qt4.2.2/X11:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication a(argc, argv);
    6. QWidget window;
    7. QVBoxLayout* layout = new QVBoxLayout(&window);
    8. layout->addWidget(new QPushButton("Dummy top button", &window));
    9. QListWidget* list = new QListWidget(&window);
    10. list->setTabKeyNavigation(false);
    11. for (int i = 0; i < 10; ++i)
    12. list->addItem(QString::number(i));
    13. layout->addWidget(list);
    14. layout->addWidget(new QPushButton("Dummy bottom button", &window));
    15. window.show();
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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.