PDA

View Full Version : How to create a TableWidgetItem with just an image?



Hookem
31st January 2009, 20:43
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

faldzip
31st January 2009, 23:00
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.