PDA

View Full Version : Visibility of QDialog



elizabeth.h1
14th October 2009, 11:41
Hello

I am doing the following :

1) I am showing dialog in my app. The dialog by default get centered over the main wndow.

2) the user moves the dialogs to some other position.

3) After the user moves the dialog to the new position I am hiding
the dialog with hide function i.e setVisible(false)

4) After hiding the dialog, after some other code, I am showing the dialog again with show i.e setVisible ( true)

Problem :
After showing the dialog it doesnot shows itself at the new positionthat was moved to i.e it shows centered on my main window.
Is this normal behavior , or should I manually preserve the position some how?

Thanks

yogeshgokul
14th October 2009, 12:33
Because of the dialog is child of main window, it has to show within parent(mainwindow) boundary.
If you want to move it to some other position. Dont create dialog as child of mainwindow or use global position like this
yourWidget->mapToGlobal( QPoint);

elizabeth.h1
14th October 2009, 13:12
"Because of the dialog is child of main window, it has to show within parent(mainwindow) boundary."

Yes, but I am not moving the dialog out of the parent boundary.
So it should not be a problem, right ?

yogeshgokul
14th October 2009, 13:23
Whats the problem in storing global position before hiding and using same position after showing.

elizabeth.h1
14th October 2009, 13:26
I think that is not elegant solution
so I want to consider some other options

nish
14th October 2009, 15:43
dont waste your time... on other "elegant" options..
you have to save your dialog's position upon hiding. this is the only way. take a look at QSettings.

axeljaeger
15th October 2009, 16:17
How do you hide the dialog? Do you maybe create a new instance of the dialog everytime you show it?

elizabeth.h1
15th October 2009, 18:40
no I do not create a new instance, am using hide nad show on the same dialog instance