Results 1 to 5 of 5

Thread: size of pixmap in tableview

  1. #1
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Unhappy size of pixmap in tableview

    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:

    Qt Code:
    1. switch (size)
    2. {
    3. case 16: model->setItem(a, b, new QStandardItem(symbol16[c], "")); break;
    4. case 24: model->setItem(a, b, new QStandardItem(symbol24[c], "")); break;
    5. case 32: model->setItem(a, b, new QStandardItem(symbol32[c], "")); break;
    6. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: size of pixmap in tableview

    QStandardItem::setIconSize()?
    Last edited by ChrisW67; 30th September 2013 at 22:03.

  3. #3
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: size of pixmap in tableview

    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?
    Last edited by Cremers; 30th September 2013 at 22:36.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: size of pixmap in tableview

    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.

  5. The following user says thank you to ChrisW67 for this useful post:

    Cremers (1st October 2013)

  6. #5
    Join Date
    May 2012
    Posts
    57
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: size of pixmap in tableview

    Thank you.
    It works great on the tableview (just when I had figured out how to do a delegate )
    But
    Qt Code:
    1. table->horizontalHeader()->setIconSize(QSize(32, 32));
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by Cremers; 1st October 2013 at 08:16.

Similar Threads

  1. Qt: How to set the size of Pixmap?
    By sonulohani in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2012, 05:37
  2. Change the size of pixmap in a label
    By metRo_ in forum Qt Programming
    Replies: 16
    Last Post: 1st June 2012, 10:21
  3. Replies: 1
    Last Post: 19th April 2011, 11:17
  4. Replies: 0
    Last Post: 7th January 2010, 22:03
  5. Drag pixmap on Windows size problem
    By plamkata in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2009, 23:01

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.