How to set the default monitor for applicaiton window.
-
I have a three monitor setup. Whenever I run my QT application the application window always shows up on the left hand monitor. I am not sure why it does this. I have tried changing my primary monitor and it still shows up on the left monitor. Is anyone aware of a setting for this in QT creator? I could not seem to find one.
-
I have a three monitor setup. Whenever I run my QT application the application window always shows up on the left hand monitor. I am not sure why it does this. I have tried changing my primary monitor and it still shows up on the left monitor. Is anyone aware of a setting for this in QT creator? I could not seem to find one.
@Circuits said in How to set the default monitor for applicaiton window.:
I am not sure why it does this.
Probably because the desktop coordinate system starts top left with (0, 0).
See:
Get primaryScreen:
List all detected/available screens:
You could specify in your
main.cppwhere your first app window should be displayed initially. -
@Circuits said in How to set the default monitor for applicaiton window.:
I am not sure why it does this.
Probably because the desktop coordinate system starts top left with (0, 0).
See:
Get primaryScreen:
List all detected/available screens:
You could specify in your
main.cppwhere your first app window should be displayed initially.@Pl45m4 said in How to set the default monitor for application window.:
You could specify in your main.cpp where your first app window should be displayed initially.
How? The primaryScreen member is defined as:
Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false)I could not find any "setter" function. I gather that I have to generate a "signal" somehow (to "notify" the primaryScreenChanged), but I'm a relative noob on Qt, and I'm not sure how to do that.
The reason I chimed in on this thread is that I have a similar problem -- except that when I run my application, it seems to sometimes randomly pick one of my 3 monitors. It's usually the monitor on which I have the IDE open, but not always.
Ideally, I would like to get a list of the monitors (QGuiApplication::screens()), and pick one that has a screen resolution of 1920x1080 and a 100% scale. I'd settle for just setting the 1920x1080 screen as my main screen.
I'm using Qt 5.14 (customer requirement) and MinGW 32-bit C++.
-
Untested: QWidget::windowHandle() and then QWindow::setScreen() on your MainWindow in main.cpp
-
Untested: QWidget::windowHandle() and then QWindow::setScreen() on your MainWindow in main.cpp
@Christian-Ehrlicher Thank you! I think I now have enough information. I'll give that a try today.
-
@Christian-Ehrlicher Thank you! I think I now have enough information. I'll give that a try today.
Or you work with your available screen geometry by setting/moving the widget to coordinates which are on the desired screen. This might require some calculations to be immune to resolution changes etc.
But you can get the geometry of every screen fromQScreen.
Say, you have 1920x1080 + 1920x1080 (both 100%), then (1921, 0) must be top left point on second screen..
[ also not tested ;-) ] -
@Christian-Ehrlicher Thank you! I think I now have enough information. I'll give that a try today.
@HowardHarkness Any luck with this?
-
@HowardHarkness Any luck with this?
@Circuits said in How to set the default monitor for applicaiton window.:
@HowardHarkness Any luck with this?
My contract ended, and I never got to try it. It was just too far down on the list of things I had to finish. I had a lot of last-minute corrections to various errors I made :)