Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does QListView support an owner draw feature?

Does QListView support an owner draw feature?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chcw
    wrote on last edited by
    #1

    I am using QListView to display a list of icons. For each icon item, I want to draw the icon by myself. Does QListView support a owner draw feature or can I override the draw event so that whenever an item is to be drawed, I can get notification and draw by myself instead of letting Qt to do that?

    Thanks

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You need to have your own delegate. When you want to have custom drawing you need to write you own delegate. Please look at writing CustomDelegate.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to Dheerendra, you are looking for the QStyledItemDelegate class

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chcw
          wrote on last edited by
          #4

          OK. Thank you. It seems that I need to override QStyledItemDelegate::paint function, to draw the following thing for an item:

          1. An icon
          2. A text
          3. A checkbox

          I have found the way of drawing checkbox. However, which event will be fired when the user clicking the checkbox? Since the checkbox is drawed by myself, how can an event be fired properly when user click it?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved