c++qtmodel-view-controllerqabstractitemview

Item is selected but isn't highlighted


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?


Solution

  • 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: