QTListView with element delegate - higher position lines for selected elements

I have a Multiple Choice QListView with the Item delegate (QStyledItemDelegate), which I use to set the size of elements and execute custom paint. My requirements are extremely simple:

  • Line height 30 for unselected items
  • Row height for selected items

There is no way to make this work.

Tried using sizeHint in my QStyledItemDelegate

if (option.state & QStyle::State_Selected)
{
  return QSize(100,60);   /// <<<<------ NEVER REACHED
}
else
{
  return QSize(100,30);
}

The state is never selected, which is strange, because the same if statement works fine for the drawing method in the same class, distinguishing between selected lines and unselected lines for different colors.

Then i tried something else

(QItemSelectionModel) sizeHint . , , , sizehint, . . 60, , . : sizeHint DRAWING, , QListView . , "" listView, . , , .

, sizeHint , . Hint - , .

:

setResizeMode (QListView:: Adjust) QListView, , , ( ) , . , , "", , QLiustView:: Adjust. ?

, , , , , . - , , QlistView 1, . (setResizeMode (QListView:: Adjust), . - NOT QListView?

+5
1

- Nokia Qt. , , , :

, , , , , . - , , QlistView 1, . (setResizeMode (QListView:: Adjust), .

+1

All Articles