0

I work with Qt/C++, and I have a QListView to display icons on screen. I set the QListView::iconMode to display it as icon view. But I cannot see that it is selected(but it is selected) it doesn't highlights. However it works for list mode. I have this.

listView->setSelectionMode(QListView::SingleSelection);
listView->setSelectionBehavior(QListView::SelectRows);

listView->setFlow(QListView::LeftToRight);
listView->setViewMode(QListView::IconMode);
listView->setWrapping(true);

can you help me?

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
tokafr
  • 109
  • 2
  • 12

2 Answers2

0

Documentation of selection rectangle:

This property holds if the selection rectangle should be visible.

If this property is true then the selection rectangle is visible; otherwise it will be hidden.

Note: The selection rectangle will only be visible if the selection mode is in a mode where more than one item can be selected; i.e., it will not draw a selection rectangle if the selection mode is QAbstractItemView::SingleSelection.

By default, this property is false.

You have to try either:

  • Manually set the property to true and see if it changes
  • Drop the single selection mode. It is compulsory? Does QAbstractItemView::ContiguousSelection suits your needs?
UmNyobe
  • 22,539
  • 9
  • 61
  • 90
0

I'm archeologist :D

Worked solution:

listView->setStyleSheet(" QListView::item:selected { border: 2px solid red; }");

You can use your own border.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
WloBeb
  • 1
  • this forbids you from using Palettes with are amazing, give them a try! [here](https://doc.qt.io/qt-5/qpalette.html) are the documents; – Ebrahim Karimi Oct 14 '20 at 18:41