I have a main widow. I move it to an bottom edge or corner. Then I open a dialog by click some button in it. The dialog is positioned at the center of the main window since I set the main window as its parent. However, the dialog is not displayed on the screen because the main window is at the edge or corner. How to make it displayed on screen?
Asked
Active
Viewed 1,905 times
1 Answers
1
You can move
it with negative coordinates until it becomes on screen:
dialog.move(-dialog.width(), -dialog.height())
This should move it so it's bottom right edge aligns with main windows's top left edge.
Or you could make the dialog parentless and move it in relation to screen coordinates instead:
dialog.setParent(None)
dialog.move(400, 300)

MadeOfAir
- 2,933
- 5
- 31
- 39
-
1Do you know how to check if it is out of screen? – user1899020 Sep 28 '13 at 05:45
-
1@user1899020: http://qt-project.org/doc/qt-5.1/qtwidgets/qwidget.html#visible-prop but you can always ask the position and compare with the screen coordinates, if the former does not work out. – László Papp Sep 28 '13 at 07:11
-
@user1899020: That probably should be another question. But that depends on the widget has a parent or not. – MadeOfAir Sep 28 '13 at 08:31