PDA

View Full Version : size of pixmap in tableview



Cremers
30th September 2013, 14:47
Hello,
I'm stuck.
I have a set of pixmaps in 3 sizes 16x16, 24x24 and 32x32.
I want to display them in a tableview:



switch (size)
{
case 16: model->setItem(a, b, new QStandardItem(symbol16[c], "")); break;
case 24: model->setItem(a, b, new QStandardItem(symbol24[c], "")); break;
case 32: model->setItem(a, b, new QStandardItem(symbol32[c], "")); break;
}


But the table always displays the small size, it's like it resizes the big ones.
When I paint them on a qimage or something, all is fine.
I tried QStandardItem::sizeHint but no go.

Thanks for your help.

ChrisW67
30th September 2013, 21:26
QStandardItem::setIconSize()?

Cremers
30th September 2013, 22:21
Hi Chris,
I get error: 'class QStandardItem' has no member named 'setIconSize'

I made it work using a delegate, but if there's a simpler solution I'd still like to know.

Well, I have the same problem with the bitmaps in the header. Can I use a delegate on the header data from QStandardModel or how is this done?

ChrisW67
30th September 2013, 22:47
Sorry, my bad (I blame early morning). QAbstractItemView::setIconSize() is a function on the view.

The QHeaderView does not implement the delegate arrangements you get on the items in the content area. You should try setIconSize() on the header also.

Cremers
1st October 2013, 07:10
Thank you.
It works great on the tableview (just when I had figured out how to do a delegate :) )
But


table->horizontalHeader()->setIconSize(QSize(32, 32));

does not seem to have any effect.

Edit: upun searching I found this:
Not all ItemDataRoles will have an effect on a QHeaderView. If you need to draw other roles, you can subclass QHeaderView and reimplement paintEvent(). QHeaderView respects the following item data roles: TextAlignmentRole, DisplayRole, FontRole, DecorationRole, ForegroundRole, and BackgroundRole.

So I guess I'm out of luck. Reimplementing paintEvent() is a bit out of my league for now.