How Can I understand where mainWindow is?
-
wrote on 15 Apr 2019, 15:26 last edited by
there is a way to understand where is the MainWindow?
I used mainWindow::pos and I noticed that when it's in the first screen MainWindow::pos().width()= -1, but I don't know if it's always -
there is a way to understand where is the MainWindow?
I used mainWindow::pos and I noticed that when it's in the first screen MainWindow::pos().width()= -1, but I don't know if it's alwayswrote on 15 Apr 2019, 15:35 last edited by@vale88 sorry, I explained badly, I saw that when mainWindow is in the first screen this->pos().x()=-1, but I don't know if it's right for all the screens
-
Hi
Why do you want to know ?
you can always check the screen its on
QScreen *screen = widget/mainwin->window()->windowHandle()->screen();
the x() should change depending on screen but i never checked it. -
Hi
Why do you want to know ?
you can always check the screen its on
QScreen *screen = widget/mainwin->window()->windowHandle()->screen();
the x() should change depending on screen but i never checked it.wrote on 15 Apr 2019, 18:59 last edited by@mrjj ok tomorrow I try, so in this way I obtain 0 or 1 and I understand which is the screen..
-
@mrjj ok tomorrow I try, so in this way I obtain 0 or 1 and I understand which is the screen..
@vale88
well you get the actual screen object.
https://doc.qt.io/qt-5/qscreen.html
It can tell you size and tons other stuff about the screen. -
@vale88
well you get the actual screen object.
https://doc.qt.io/qt-5/qscreen.html
It can tell you size and tons other stuff about the screen.wrote on 16 Apr 2019, 10:35 last edited by@mrjj if I write this I obtain the name of the screen , but I need only to know if it's the first screen or the secondary
-
@mrjj if I write this I obtain the name of the screen , but I need only to know if it's the first screen or the secondary
@vale88
Hi
try
(do not call from constructor as windowHandle() is not set there yet)QScreen *screen = this->window()->windowHandle()->screen(); if ( QGuiApplication::primaryScreen() == screen ) qDebug() << "yes!";
6/7