Results 1 to 2 of 2

Thread: Automatic image resizing too slow

  1. #1
    Join Date
    Nov 2009
    Posts
    15

    Default Automatic image resizing too slow

    I am going to write my problem here because I am slightly lost ...

    In design of a MainWindow I have three widgets that lay out horizontally in one splitter. The splitter has no special attributes except setCollapsible(x, false) .
    In the third widget (right pos) I have a label that contains a QPixel for displaying a image. That image resizes itself when the user changes the size of the MainWindow (when QWidget::resizeEvent emits its signal).
    To find out the final size of the image I check the size of the label (with Expanding attribute in sizePolicy) and, if the image size is major than the new size of the label, apply it to the QPixmap with this (incomplete) code:

    Qt Code:
    1. QPixmap pix ;
    2. QSize sizex(imageContainer->size()) ;
    3.  
    4. imageContainer->setPixmap(pix.scaled(sizex,
    5. Qt::KeepAspectRatio, Qt::SmoothTransformation));
    To copy to clipboard, switch view to plain text mode 

    The problem is when I horizontally resize the window (vertically has no problems) and splitter resize its content. The process has a lot of time to finish. I resize the window and splitter panels take a size that is changing slowly as the size of the label is fitting.
    I think that Label's size doesn't fit until the main window doesn't stop changing its size.
    I can throw the change of size when the main window stops fitting, but then the process becomes very sudden.
    The problem only happens when the window has splitters. When I try the code in a window with one widget, resize works correctly.

    Any ideas?

  2. #2
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Thanks
    6
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Automatic image resizing too slow

    According to Qt Documentationo of QWidget::resizeEvent
    The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.

    you don't mencioned in what function scale the pixmap, if the pixmap is called in the funtion resize event, MAYBE that is the problem. indirectly you enforce a redraw of the widget, but i need see the your source code.

    try to use Qt::FastTransformation instead of Qt::SmoothTransformation.
    Qt Code:
    1. imageContainer->setPixmap(pix.scaled(sizex, Qt::KeepAspectRatio, Qt::FastTransformation));
    To copy to clipboard, switch view to plain text mode 

    Another detail. resizeEvent is a event not a Qt signal. Signals are useful when using a widget, whereas events are useful when implementing a widget.

    sorry my poor english. my natural lenguege is spanish
    Last edited by ecanela; 14th December 2009 at 09:24. Reason: updated contents

Similar Threads

  1. resizing an image without interpolation
    By mattei in forum Qt Programming
    Replies: 3
    Last Post: 9th December 2009, 12:10
  2. Very slow repainting ofPixmaps in QGraphicsView images
    By drexiya in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2009, 19:13
  3. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 16:36
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 03:10
  5. Automatic Resizing
    By ToddAtWSU in forum Qt Programming
    Replies: 7
    Last Post: 22nd January 2007, 19:41

Tags for this Thread

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.