View Full Version : Automatic image resizing too slow

10th December 2009, 14:09
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:

QPixmap pix ;
QSize sizex(imageContainer->size()) ;

Qt::KeepAspectRatio, Qt::SmoothTransformation));

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? :confused:

14th December 2009, 08:55
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.

imageContainer->setPixmap(pix.scaled(sizex, Qt::KeepAspectRatio, Qt::FastTransformation));

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