Results 1 to 2 of 2

Thread: How to create a TableWidgetItem with just an image?

  1. #1
    Join Date
    Dec 2008
    Posts
    13

    Default How to create a TableWidgetItem with just an image?

    I have tried in vain to add an image to a TableWidgetItem where it is the only component in the cell. When it's added as an icon with no text, the column is never centered because there is an empty text component next to it.

    When I add it is a background image (brush<-pixmap) it shows in textured format. I just want one, and there's no texture option to simply tell it to not replicate.

    When I try to add it as a foreground or use the foreground brush, it just doesn't show up.

    I can't add a label as a widget item either.

    Honestly, with the way Qt makes most things easier I'm surprised this is so difficult. All I want to do is add an image to a cell and make it be the only thing. How do I do that?

    Thanks

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to create a TableWidgetItem with just an image?

    As for me, you should create your own item delegate, which will draw your image in that cell. Look at the Pixelator example in Example & Demos. I think that your QAbstractItemDelegate::paint() method would be even more simple than that one from that example.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. How can I create a transparent image with QImage?
    By learning_qt in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2009, 15:06
  2. Using a 2d data array to create an image
    By dbrmik in forum Newbie
    Replies: 20
    Last Post: 28th October 2008, 17:22
  3. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  5. Create pixmap image from string
    By Morea in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2006, 16:38

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.