Important: Please read the Qt Code of Conduct -

QStyledItemDelegate: height for width

  • Hi

    What is the best way to implement ItemDelegate that changes it's height when view is resized?

    I want to implement my own "very special" item delegate for QTableWidget in such a manner that it will have different height depending if I can layout all the data in a single line or not. In later case (item's width was too small) I want to make it taller, thus I would be able to put data into several lines. Width of the item is obviously correlated with width of QTableWidget.

    The problem is that in delegate's sizeHint() function there is no way to find out anything about TableView's size to make decision about what kind of layout's should I be using.

  • Well, may be I should be passing pointer to view as a parameter of ItemDelegate?
    But this looks like a hack and I would prefer avoiding this approach.

  • no, it doesn't work anyway: rows heights seem not to be updated dynamically at all.

Log in to reply