QMainWindow opens in the screen where the mouse is currently in
-
I noticed that when I launch a
QMainWindow
application (it might be the same with a simpleQWidget
) it opens in the screen where the mouse is in that moment. Of course, if you have multiple screens.This is not a standard Windows behavior, other applications seem not to follow this rule. Sometimes it's annoying... is there anything that we can disable?
-
I noticed that when I launch a
QMainWindow
application (it might be the same with a simpleQWidget
) it opens in the screen where the mouse is in that moment. Of course, if you have multiple screens.This is not a standard Windows behavior, other applications seem not to follow this rule. Sometimes it's annoying... is there anything that we can disable?
@Mark81 said in QMainWindow opens in the screen where the mouse is currently in:
This is not a standard Windows behavior, other applications seem not to follow this rule
i saw quite some applications which behave this way actually.
Why should it exactly spawn in a particular position? -
@raven-worx Well, why it should not? :-) I find very annoying that it spawns here or there where it finds my mouse in that moment... Anyway, I understand these are just opinions. The question is if there's a way to change the default beahvior.
-
I noticed that when I launch a
QMainWindow
application (it might be the same with a simpleQWidget
) it opens in the screen where the mouse is in that moment. Of course, if you have multiple screens.This is not a standard Windows behavior, other applications seem not to follow this rule. Sometimes it's annoying... is there anything that we can disable?
//Constructor { .... QMetaObject::invokeMethod(this, &MainWindow::afterStartup,Qt::QueuedConnection); } MainWindow::afterStartup() { auto screens = QApplication::screens(); if(screens.size() >1) { //more than 1 scrren, move window whereever you want it to move( x, y); } }
-
//Constructor { .... QMetaObject::invokeMethod(this, &MainWindow::afterStartup,Qt::QueuedConnection); } MainWindow::afterStartup() { auto screens = QApplication::screens(); if(screens.size() >1) { //more than 1 scrren, move window whereever you want it to move( x, y); } }
You can do that after the object's become valid, there's no need to queue it through the event loop.
-
You can do that after the object's become valid, there's no need to queue it through the event loop.
@kshegunov
this is just from the top of my head. I don't know when or where the Object becomes valid, without looking it further up. So I simply queued it to be sure, that it's after the complete setup -
@kshegunov
this is just from the top of my head. I don't know when or where the Object becomes valid, without looking it further up. So I simply queued it to be sure, that it's after the complete setup@J.Hilk said in QMainWindow opens in the screen where the mouse is currently in:
this is just from the top of my head. I don't know when or where the Object becomes valid, without looking it further up. So I simply queued it to be sure, that it's after the complete setup
Not an error, just sayin'.
-
@J.Hilk said in QMainWindow opens in the screen where the mouse is currently in:
this is just from the top of my head. I don't know when or where the Object becomes valid, without looking it further up. So I simply queued it to be sure, that it's after the complete setup
Not an error, just sayin'.
It is an error from consumer POV, because it does that even if instructed not to, if originally was instrcted to be open on "main" screen. Worse, using Qt functionality to open Window on particular display is ignored for display "0.0" .
Funny, that after this numbering of screens for app changes. If several applications are started, each got screen number 0 as they were launched on.
Imagine a multiscreen setup where several windows have to be opened on separate screens. It's a hardware monitoring station, after clicking the icon. I encounter this effect since Qt 4.8.7 that QMainWindow always jumps to the mouse's location, on Xorg only.
A "hack" to put start icon on right screen doesn't work because user is able to move cursor faster than app is launched.
Neither Windows nor Wayland behavour offer the same, so I supect that X11 window managers are the culprit.