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

kajojeq
  • 886
  • 9
  • 27
  • 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? – Jablonski Nov 18 '14 at 15:11
  • 1
    I gave more detailed info what I want to reach Thanks for effort. – kajojeq Nov 18 '14 at 16:00
  • 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)? – Jablonski Nov 18 '14 at 16:07
  • 1
    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. – kajojeq Nov 19 '14 at 07:05

0 Answers0