Results 1 to 2 of 2

Thread: QPixmap not getting resized with scaled()

  1. #1
    Join Date
    Jan 2013
    Location
    Bangalore
    Posts
    49
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPixmap not getting resized with scaled()

    hai, i am resizing the image with scaled function, but it is beeing with the ame size only. i want to decrese size of the image, so that they will take less memory.
    i am displaying 1000 images on scene so it is taking more memory because of ths issue. how i have to reduce the sie of Qimage and display them on scene as a thumbnile .

    Qt Code:
    1. QImage image = tempImage; // is 1025*724
    2. image.scaled(50,50,Qt::KeepAspectRatio);
    3. item = new QGraphicsPixmapItem(QPixmap::fromImage(image));
    4. scene->addItem(item);
    To copy to clipboard, switch view to plain text mode 

    after scaling it still the image size is same as old temp image size only.

  2. #2
    Join Date
    Nov 2011
    Location
    India
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPixmap not getting resized with scaled()

    Check the signature of QPixmap::scaled
    Its a const method i.e. it will not change the object state. What you need is this :-
    .
    .
    image = image.scaled(50,50,Qt::KeepAspectRatio);
    .
    .

Similar Threads

  1. Add letterbox to resized QPixmap
    By Jay-D in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2013, 03:52
  2. QPixmap::grabWidget on a scaled Phonon::VideoWidget?
    By linus in forum Qt Programming
    Replies: 0
    Last Post: 6th April 2010, 13:19
  3. widget not resized within QDockWidget
    By pospiech in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2008, 18:19
  4. poor Quality after QPixmap::scaled()
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 1st October 2007, 21:43
  5. QTreeWidget - preventing columns from being resized.
    By sternocera in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2007, 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
  •  
Qt is a trademark of The Qt Company.