Results 1 to 3 of 3

Thread: Can I use a QWidget as a renderer in an ItemDelegate?

  1. #1

    Default Can I use a QWidget as a renderer in an ItemDelegate?

    Hi all,

    For those familiar with the ListCellRenderer concept in Swing, is there a way to do the equivalent with QT?

    I have to implement a custom delegate for my listview, but the layout is a bit complicated (see the attached file to see an example of what i want to do).

    In swing, as i remember it, i would create this layout in a component, and use this component as a stamp to paint each row.

    I can't figure out how to do the same with QT. I'd like my delegate to have a single instance of a component. Each time paint() is called on my delegate, i would populate this component with data for the current row, then render this component to paint the row.

    Is this possible? Or is there a better way that i'm missing?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Can I use a QWidget as a renderer in an ItemDelegate?

    Hi,

    what you can do is to create your own QWidget with all the other stuff inside, resize it to the available space and then use
    Qt Code:
    1. QPixmap pixmap(widget->size());
    2. widget->render(&pixmap);
    To copy to clipboard, switch view to plain text mode 
    Then you can simply set the image wherever you want, but that's not very efficient. For your design just use the normal painter function like drawPixmap, drawText etc. It isn't that difficult.

  3. #3

    Default Re: Can I use a QWidget as a renderer in an ItemDelegate?

    Thanks, i'll try the pixmap approach.

Similar Threads

  1. QtScript Binding problem with QWidget
    By zack in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2009, 09:38
  2. Replies: 0
    Last Post: 11th November 2008, 15:36
  3. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  4. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  5. Replies: 3
    Last Post: 8th March 2007, 14:54

Tags for this Thread

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.