Results 1 to 2 of 2

Thread: QListWidget delegate

  1. #1
    Join Date
    Feb 2021
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    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
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QListWidget delegate

    I have tried :

    Qt Code:
    1. void paint(QPainter *painter,
    2. const QStyleOptionViewItem &option,
    3. const QModelIndex &index) const override {
    4.  
    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);
    14.  
    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 21: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, 12:37
  2. Replies: 5
    Last Post: 10th October 2011, 14:26
  3. Replies: 2
    Last Post: 1st April 2011, 10:32
  4. QListWidget delegate paint problem.
    By rule in forum Qt Programming
    Replies: 0
    Last Post: 5th July 2010, 14:31
  5. Need help with my delegate
    By Guilo in forum Qt Programming
    Replies: 6
    Last Post: 1st July 2010, 13:15

Bookmarks

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.