PDA

View Full Version : QResizeEvent called 3 times



mvbhavsar
17th December 2014, 13:12
I have a call which has implemented QMainWindow. I want to call a funtion when it is maximized. Hence I have reimplemented resize event of QMainWindow. But I call this function inside this event, it gets called 3 times since in main class I have writtern app.showMaximized();

Can any one let me know I resize event gets call multiple times.



Thanks

Manish

anda_skoa
17th December 2014, 13:42
Have you checked the values?

Maybe the windowing system resizes the window three times?

Cheers,
_

mvbhavsar
17th December 2014, 13:46
Yes, I have checked the values, it is show old values of size as (-1,-1) then (680,420) and (680,420)

anda_skoa
17th December 2014, 14:56
Does the windowState() change at one of these three?

Cheers,
_

Radek
17th December 2014, 15:06
Just guessing: the calls are "on the way" calls during resolving the geometry (ctor, layouts, decorations and so on). As to your attempts: do not connect() resize(), call showFullScreen() or showMaximized() from your handler (or the ctor) and then call size(). As to the documentation, you could get some problems with X. You need to try.

mvbhavsar
17th December 2014, 16:07
WindowState is definitely changed once. Since during design time in QT Creator, QMainWindow has its default size when created using new application wizard. But when I run the application, I have mentioned showMaximized to the instance of class which has extended QMainWindow class.

In the class which has extended QMainWindow, I have re-implemented resize event and have capture that if change.type() == QWindowStateChange and then isMaximized() function. Then only I am calling my custom code. But despite this it is calling 3 times.

WindowState is definitely changed once. Since during design time in QT Creator, QMainWindow has its default size when created using new application wizard. But when I run the application, I have mentioned showMaximized to the instance of class which has extended QMainWindow class.

In the class which has extended QMainWindow, I have re-implemented resize event and have capture that if change.type() == QWindowStateChange and then isMaximized() function. Then only I am calling my custom code. But despite this it is calling 3 times.