Qt 6.5.3 : Can't change QWidget position
-
Hello everyone.
I have problem with my QWidget window which I can't update position.
I don't use the Ui tool.(aw_ is a QWidget)
I've tried:
QRect screenGeometry; int x; int y; screenGeometry = QApplication::primaryScreen()->geometry(); x = (screenGeometry.width() - aw_.width()) / 2; y = (screenGeometry.height() - aw_.height()) / 2; aw_.move(x, y); aw_.show();
but the window doesn't move.
I also tried :
QRect screenGeometry; int x; int y; screenGeometry = QApplication::primaryScreen()->geometry(); x = screenGeometry.center().x(); y = screenGeometry.center().y(); aw_.setUpdatesEnabled(true); aw_.setGeometry(x, y, 400, 300); QApplication::processEvents(); aw_.show();
There the size of the window changed but remains stuck a random point on the screen.
I also tried to create a new project with a Ui and I saw in the Design panel that the values of X and Y of the geometry property can't be changed (they're disabled) but not width and height.
Does anyone has an idea?
Thanks in advance.
-
Hello everyone.
I have problem with my QWidget window which I can't update position.
I don't use the Ui tool.(aw_ is a QWidget)
I've tried:
QRect screenGeometry; int x; int y; screenGeometry = QApplication::primaryScreen()->geometry(); x = (screenGeometry.width() - aw_.width()) / 2; y = (screenGeometry.height() - aw_.height()) / 2; aw_.move(x, y); aw_.show();
but the window doesn't move.
I also tried :
QRect screenGeometry; int x; int y; screenGeometry = QApplication::primaryScreen()->geometry(); x = screenGeometry.center().x(); y = screenGeometry.center().y(); aw_.setUpdatesEnabled(true); aw_.setGeometry(x, y, 400, 300); QApplication::processEvents(); aw_.show();
There the size of the window changed but remains stuck a random point on the screen.
I also tried to create a new project with a Ui and I saw in the Design panel that the values of X and Y of the geometry property can't be changed (they're disabled) but not width and height.
Does anyone has an idea?
Thanks in advance.
-
@paulo95
If/assuming you are running under Wayland you will find you can do little to position windows. Several threads in this forum to that effect. Use Xorg if you must do so.Thanks for you answer.
Yes I'm under Wayland.
Already had problem with it : had marshal_proxy_plugin error when running empty QtWidget Application under Debian 11. Had to migrate to Debian 12 to have recent version of libwayland.Currently switching to Xorg at login screen makes me gray screen.
I'm keeping you posted when solved this and tried. -
Thanks for you answer.
Yes I'm under Wayland.
Already had problem with it : had marshal_proxy_plugin error when running empty QtWidget Application under Debian 11. Had to migrate to Debian 12 to have recent version of libwayland.Currently switching to Xorg at login screen makes me gray screen.
I'm keeping you posted when solved this and tried. -