Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Setting selection in QListView widget
RogerCleg last edited by
I'm a new Qt developer. Can anyone tell me how I would force a selection in a QListView widget?
Jeroentjehome last edited by
Not really sure what you mean. What do you want to force? Or do you just want a line selected at all times? Maybe a small picture with it to show what you need.
Sam last edited by
Welcome to the Forum,
I agree that you can be a bit more clear about your requirements. An image will be perfect as discussed above. From my assumptions of force selection in a QListView, i think you want
a. Forcefully select an particular index/row on start up
ans. You can get the QModelIndex for the particular row and use "setSelectedIndex(index)":http://doc.qt.digia.com/qt/qabstractitemview.html#setCurrentIndex funtion and through stylesheets you can change the border-color or width.
b. To set the focus on QListView.
ans. check "setFocus()":http://doc.qt.digia.com/qt/qwidget.html#setFocus