Results 1 to 1 of 1

Thread: How to draw raised panel around each list item

  1. #1
    Join Date
    Oct 2009
    Qt products

    Default Re: How to draw raised panel around each list item


    I was trying to understand how to properly reimplement paint method for QStyledItemDelegate so it draws each list item on a panels (like QFrame with frameShape=Panel and frameShadow=Raised).

    I understand I need to use QStyle::drawPrimitive to do that, but here are my questions:
    1. how to find proper primitive if I know the widget type the primitive should look like?
    2. how do I find correct QStyledOption class for that and how can I understand what options to set in there?
    3. if in addition to the raised panel I want to draw two iconed buttons on the right of the item, how do I make them behave as buttons actually?

    What I finally what to achieve is something like this, I have a list of small selectable panels with a text on the center, check box on the right and two buttons on the left. If a check box on an item is not checked then the whole item is displayed semi-transparent, it should be displayed opaque otherwise. If user hits left button, the item should be moved one position up. If user hits right button, the item should be moved one position down (Or if its not very difficult, I would go even for drag-&-dropping them in the list)

    How do I do that, and where do I read on how to properly reimplement QStyledItemDelegate:aint. I tried to find it in the assistance but apart from a very easy example with stars (which does not help at all) I could not find any explanations.

    Thank you in advance!

    Added after 1 8 minutes:

    As an extra question: would it be better / more correct to implement what I want as a list of real widgets in a vertical layout?

    Even if this is better I still hope to get the answers on the questions above, as I still don't understand how to I implement paint method using the style and options. The general idea is clear but the detail are always the evil (good explanation link would be very helpful, as I still can not find any good info on this in the assistant. Everywhere only highveiw stuff is written and said that I need to go to another class documentation for more details, but if I go there I dont get anything new apart from the next promise to see the details in a next class documentation...)
    Last edited by topoden; 5th January 2011 at 02:12.

Similar Threads

  1. style a list item
    By savar in forum Newbie
    Replies: 3
    Last Post: 18th March 2010, 18:21
  2. How to owner draw the item for QListWidget?
    By tszzp in forum Qt Programming
    Replies: 2
    Last Post: 27th November 2009, 02:41
  3. Replies: 4
    Last Post: 9th May 2008, 21:56
  4. raised view of Widgets.
    By in forum Qt Programming
    Replies: 22
    Last Post: 25th January 2007, 11:21
  5. deleting first item in a list
    By soul_rebel in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 17:49


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.