Results 1 to 2 of 2

Thread: Drawing a small rect on each item of a QListWidget

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Drawing a small rect on each item of a QListWidget

    Good morning,
    I don't have enough experience on model/view.
    I am reading docs but i can not find what I need.
    I have elements of a QListWidget. Each element has a checkbox and a string.
    I would draw a small colored rectangle between the checkbox and the string.
    How can I do? I know I have to use delegate but I can not find a similar example.
    Thanx to all,
    Franco
    Franco Amato

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Drawing a small rect on each item of a QListWidget

    You can specify a QIcon for each QListWidgetItem. Maybe you can create QIcon instances for each color and assign those? A lot easier than a delegate, and you would have to create a unique delegate for each color anyway unless you also added a custom data role to each item that specified the color.

    However, I do not know if icons and check boxes can live together in the same item. It would be easy to try that experiment first before launching into designing a delegate.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    franco.amato (27th October 2020)

Similar Threads

  1. Drawing Rect on QwtPlot
    By baray98 in forum Qwt
    Replies: 4
    Last Post: 26th October 2012, 17:34
  2. Drawing atoms / small balls/spheres in QGLWidget ?
    By hgedek in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2011, 22:18
  3. Replies: 0
    Last Post: 1st November 2010, 09:22
  4. Focus rect not drawing
    By draftpunk in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2008, 16:21
  5. Replies: 3
    Last Post: 7th November 2006, 09:35

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.