PDA

View Full Version : QWidget::pos Appears Unreliable



mbrusati
25th February 2009, 01:14
Are there known problems calling QWidget's pos() function from closeEvent? I have an application running under Linux/X11 that uses QSettings to persist the size and location of QWidgets. As recommended in the Qt docs, I read the settings in the constructor and write them in the widget's closeEvent function. The behavior I see is that the position written to the settings files is often (though not always) incorrect. Could it be that QWidget's pos() function cannot be counted on when called from closeEvent?

mbrusati
25th February 2009, 18:01
I've discovered something new since my original post. I record the position and size of a QDialog in overridden moveEvent and resizeEvent functions. When I close the dialog I record position and size using QSettings. What I'm seeing is this: Occassionally I will get a moveEvent that reports the position incorrectly, and the bogus move event seems to always occur after a show event. For example, if I print the position of the dialog from showEvent it may correctly report the position to be (500, 600). But sometimes a move event will follow the show event and it will incorrectly report the position, e.g. (0, 0). This is occurring under Linux/X11. Has anyone else seen such behavior?