Results 1 to 3 of 3

Thread: QPixmap from QVairant

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QPixmap from QVairant

    Hello,
    I have QStandardItemModel with QPixmap on first column. I want scale pixmaps but I can't figure out how to copy them back to tmp pixmaps.

    Qt Code:
    1. QPixmap tmp = QPixmap( model.data( model.index( i, 0 ), Qt::DecorationRole ).toByteArray() );
    2. //tmp is empty
    3. //at index i,0 are Pixmaps
    To copy to clipboard, switch view to plain text mode 

    Any suggestion are more then welcome.

    EDIT:
    Qt Code:
    1. qDebug() << model.data( model.index( i, 0 ), Qt::DecorationRole ).type();
    2. //out: QVariant::QPixmap
    To copy to clipboard, switch view to plain text mode 
    Last edited by Talei; 3rd April 2010 at 15:53.

  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: QPixmap from QVairant

    Hi,
    use
    Qt Code:
    1. QPixmap tmp = model.data( model.index( i, 0 ), Qt::DecorationRole ).value<QPixmap>();
    To copy to clipboard, switch view to plain text mode 

    Lykurg

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QPixmap from QVairant

    Thank you. I had value<QPixmap>; without () that's why error... eh.

Similar Threads

  1. Replies: 4
    Last Post: 28th August 2008, 13:13
  2. Replies: 1
    Last Post: 21st August 2008, 07:44
  3. QPixmap bug under Qt4.3.1 ?
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 7th October 2007, 17:04
  4. Replies: 5
    Last Post: 9th April 2007, 14:26
  5. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 17:11

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
  •  
Qt is a trademark of The Qt Company.