Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Changing editor size in QStyledItemDelegate



  • Hi,
    I have a QStandardItemModel with QStyledItemDelegate. Because the records include pictures the rows are quite high and the editors (QLineEdit, QTextEdit, QComboBox) don't look too good. Is it possible to change the size of these editors somehow? Especially their height.
    Thank you.


  • Lifetime Qt Champion

    Hi
    Can you try in
    In
    ::createEditor(QWidget *parent,
    const QStyleOptionViewItem &option,
    const QModelIndex &index) const
    ....
    StarEditor *editor = new StarEditor(parent); // Create editor
    editor->resize( option.rect.width(), option.rect.height() )
    ....



  • I think reimplementing sizeHint in the delegate should be enough


Log in to reply