QListView selection with highlight/hover
Asked Answered
C

0

2

How to do item in QListView selected as I would click on him? Way I tried to do this I have selection but like not-active one. Without Blue highlight only grey one.

To be mroe detailed:

  1. Make QListView
  2. AddSomeItems
  3. Run app
  4. Move mouse to any item
  5. Select it
  6. Now its, selected and ALSO blue. This is what I want to do with item before I run application. If it is possible of course. (selectable + hover + focus?)

enter image description here

I want to have it without clicking

I tried many ways:

view->clicked(selectedIndex);
view->selectionModel()->select( selectedIndex, QItemSelectionModel::Select )
view->setCurrentIndex(selectedIndex);
view->clicked(selectedIndex);

and others, any help needed

Coulomb answered 18/11, 2014 at 11:9 Comment(4)
So QModelIndex ind = ui->listView->model()->index(1,0); ui->listView->setCurrentIndex(ind); ui->listView->selectionModel()->select(ind,QItemSelectionModel::Select); is not what are you looking for? Do you want blue color as user hover mouse on item?Artist
I gave more detailed info what I want to reach Thanks for effort.Coulomb
Do you want that selected item had blue color(as in hover state) every time in app, if user don't hover item, item should have blue color(as in hover state)?Artist
I want to select item as it would be clicked, thats all. As you would click it but without clicking (inside program). Other words: Create QComboBox, When you open it you will see QLIstView and one item will be selected as it was clicked, I want the same effect on my QListView without QComboBox.Coulomb

© 2022 - 2025 — McMap. All rights reserved.