
Originally Posted by
divanov
This is very strange solution. Did you try to use QWidget::setEditFocus() for QListWidget?
Just for the record, it is not mandatory to make any special key event handling to do line select in listWidget.
Code:
//connect is the key for the "select"-button to work
connect(listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(selectAction(QListWidgetItem*)));
//setEditFocus(true) removes the needed first click that was mentioned in the first post.
//Now "up" and "down"-button presses moves the selection in listWidget.
listWidget->setEditFocus(true);
//remember to declare selectAction(QListWidgetItem* selectedItem) as slot!
void someClass::selectAction(QListWidgetItem* selectedItem){
//do something
}