View Full Version : Tab navigation and QListWidget
Arthur
6th March 2007, 11:39
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
You can disable tab key navigation (http://doc.trolltech.com/4.2/qabstractitemview.html#tabKeyNavigation-prop) on the view.
Arthur
9th March 2007, 14:45
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...
guilugi
9th March 2007, 16:24
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...
Arthur, have you reimplemented any event handlers?
Here's an example which works fine for me with Qt4.2.2/X11:
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QWidget window;
QVBoxLayout* layout = new QVBoxLayout(&window);
layout->addWidget(new QPushButton("Dummy top button", &window));
QListWidget* list = new QListWidget(&window);
list->setTabKeyNavigation(false);
for (int i = 0; i < 10; ++i)
list->addItem(QString::number(i));
layout->addWidget(list);
layout->addWidget(new QPushButton("Dummy bottom button", &window));
window.show();
return a.exec();
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.