Important: Please read the Qt Code of Conduct -

Does QStyledItemDelegate handle required space for the item in the view

  • Say using a delegate I have a rectangle drawn in each index with varying height based on a particular width.

    When i maximise (resize) this view based on the new width available from option.rect.width() I calculate a new height for each item and the corresponding paint event draws the new rectangle as intended.

    However since the rectangle's height has come down for most elements in the maximised state the gap between elements appear larger which just looks wrong.

    Am wondering is there something i need to do extra here to tell the view that the size of each item has changed from before apart from the sizeHint property so that it draws the next element closer.

    "Normal View":

    "Maximised View":

    In Each Image the text in blue is the value of the item's height.

    Am confused since the item's height has indeed come down but the view still appears to be giving the item the same height as before

  • Got a solution with QListView::Adjust as resizeMode

    Seems a bit overkill to have the view lay the items everytime if a resize occurs without knowing its actually needed to re-position.

    Guess thats the only option for now tho.

Log in to reply