Results 1 to 2 of 2

Thread: QListWidget delegate

  1. #1
    Join Date
    Feb 2021
    Qt products

    Default QListWidget delegate

    Can anyone help me with some custom delegate for QListWidget. I want fust when i expand some item to show its children under top item aligned to left (like QComboBox has). Remain scrollbars etc. Only to remove indentation of items.
    I have already tryed to make custom delegate with various changes but nothing works yet, which property should i change...
    Thanks very much.

  2. #2
    Join Date
    Feb 2021
    Qt products

    Default Re: QListWidget delegate

    I have tried :

    Qt Code:
    1. void paint(QPainter *painter,
    2. const QStyleOptionViewItem &option,
    3. const QModelIndex &index) const override {
    5. if(index.child(0, 0).isValid()) {
    6. QStyleOptionViewItem viewOptions;
    7. viewOptions.rect = option.rect;
    8. viewOptions.displayAlignment = Qt::AlignLeft;
    9. viewOptions.decorationAlignment = Qt::AlignLeft;
    10. viewOptions.viewItemPosition = QStyleOptionViewItem::Beginning;
    11. viewOptions.decorationPosition = QStyleOptionViewItem::Left;
    12. viewOptions.textElideMode = Qt::ElideLeft;
    13. QApplication::style()->drawControl(QStyle::CE_PushButton, &viewOptions, painter);
    15. }
    16. QItemDelegate::paint(painter, option, index);
    17. }
    To copy to clipboard, switch view to plain text mode 

    but children item padding is still indented
    Last edited by d_stranz; 8th April 2021 at 20:02. Reason: missing [code] tags

Similar Threads

  1. How to do QChartView delegate like QTableView item delegate
    By malleeswarareddy.s in forum Qt Programming
    Replies: 0
    Last Post: 16th September 2015, 11:37
  2. Replies: 5
    Last Post: 10th October 2011, 13:26
  3. Replies: 2
    Last Post: 1st April 2011, 09:32
  4. QListWidget delegate paint problem.
    By rule in forum Qt Programming
    Replies: 0
    Last Post: 5th July 2010, 13:31
  5. Need help with my delegate
    By Guilo in forum Qt Programming
    Replies: 6
    Last Post: 1st July 2010, 12:15


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.