Results 1 to 3 of 3

Thread: How to owner draw the item for QListWidget?

  1. #1
    Join Date
    Oct 2009
    Posts
    32
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question How to owner draw the item for QListWidget?

    I want to owner draw the item for QListWidget, not simple change the background color,and I notice the QListWidget isn't derived from QWidget, so it hasn't the paintEvent. how to implement it? thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to owner draw the item for QListWidget?

    and I notice the QListWidget isn't derived from QWidget, so it hasn't the paintEvent.
    QWidget > QFrame > QAbstractScrollArea > QAbstractItemView > QListView > QListWidget.
    See the inheritance ? so paintevent is available in QListWidget.
    However for your need, its simple to use delegates. Have a look at QItemDelegate and QStyledItemDelegate

  3. #3
    Join Date
    Oct 2009
    Posts
    32
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How to owner draw the item for QListWidget?

    Quote Originally Posted by aamer4yu View Post
    QWidget > QFrame > QAbstractScrollArea > QAbstractItemView > QListView > QListWidget.
    See the inheritance ? so paintevent is available in QListWidget.
    However for your need, its simple to use delegates. Have a look at QItemDelegate and QStyledItemDelegate
    Sorry, I type error. I want to type the QListWidgetItem. thank you for your reply. I will try to use the QItemDelegate to owner draw the item for QListWidget. thanks.

Similar Threads

  1. How to owner draw the scrollbar in Qt?
    By tszzp in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2009, 01:56
  2. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37

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.