Results 1 to 2 of 2

Thread: refreshing QPixmap

  1. #1
    Join Date
    Apr 2010
    Location
    Katowice, Poland
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default refreshing QPixmap

    Hi!
    Is it possible to refresh the picture viewed by QPixmap? I have the QPixmap object with given picture and when I'll click the button it should refresh (because in the meantime this picture has changed)... I've looked in API for something like this, but with no result.
    Thanks in advance!

  2. #2
    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: refreshing QPixmap

    QPixmap in representation of data in the mem, so you don't display pixmap but view pixmap in i.e. qlabel. Do something like this:
    Qt Code:
    1. px.load("image1.ext");
    2. ui->label->setPixmap(px);
    3.  
    4. //and on button press
    5. px.load("image2.ext");
    6. //or
    7. //QByteArray ByteArrayImage;
    8. //px.loadFromData( ByteArrayImage );
    9. ui->label->setPixmap(px);
    To copy to clipboard, switch view to plain text mode 

    EDIT: You could use, on button press, something like this also:
    Qt Code:
    1. ui->label->setScaledContents( false );
    2. ui->label->update( ui->label->rect() );
    3. ui->label->setScaledContents( true );
    To copy to clipboard, switch view to plain text mode 
    or repaint. If you don't setScaledContents(false) then true image don't show, assuming that scaledContents was true.
    Last edited by Talei; 18th April 2010 at 03:06.

Similar Threads

  1. Replies: 4
    Last Post: 28th August 2008, 13:13
  2. Replies: 1
    Last Post: 21st August 2008, 07:44
  3. Replies: 5
    Last Post: 9th April 2007, 14:26
  4. Refreshing problem
    By jaime in forum Qt Programming
    Replies: 3
    Last Post: 24th August 2006, 22:09
  5. Refreshing QDataTable
    By zlatko in forum Qt Programming
    Replies: 5
    Last Post: 2nd May 2006, 16: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.