Why a window (subclass of QWidget) moves after being closed and opened
-
I define a new subclass of QWidget, QMyWindow, as a customized window.
QMyWindow * pMyWindow = new QMyWindow(nullptr); pMyWindow->setAttribute(Qt::WA_QuitOnClose, false); pMyWindow->move(0, 0); pMyWindow->show(); //user can do something and then close it pMyWindow->show(); //and its position is lower than before
Every time after being closed and opened, its position becomes lower and lower.
-
Maybe it's a problem with that version that has been fixed. Can you try the latest? As I said - seems to be working fine for me with 5.15.2.
-
@a364858 said in Why a window (subclass of QWidget) moves after being closed and opened:
Every time after being closed and opened, its position becomes lower and lower.
This is done by the window manager I guess. What is your OS/window manager?
-
@jsulm said in Why a window (subclass of QWidget) moves after being closed and opened:
@a364858 said in Why a window (subclass of QWidget) moves after being closed and opened:
Every time after being closed and opened, its position becomes lower and lower.
This is done by the window manager I guess. What is your OS/window manager?
Windows 10.
What's more, it won't get lower and lower if move() is not called.
QMyWindow * pMyWindow = new QMyWindow(nullptr); pMyWindow->setAttribute(Qt::WA_QuitOnClose, false); pMyWindow->show(); //default position //user can do something and then close it pMyWindow->show(); //and it won't move
-
Works correctly for me with Qt 5.15.2 and QWidget or QMainWindow. Maybe it's something specific to your QMyWindow class? Do you have something in its show event maybe? Can you try replacing it with a simle QWidget and see if it still happens? Which Qt version are you using?
-
This post is deleted!
-
-
Maybe it's a problem with that version that has been fixed. Can you try the latest? As I said - seems to be working fine for me with 5.15.2.