-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.3.2, 5.4.0
-
OS X 10.9.4
On multi monitor setup
widget->windowHandle()->screen()->geometry()
will always initially report the rect of the main screen (screen 0) even if the window is shown on a different screen.
Only after the window is moved to the main screen and back to the second it will start reporting correct dimensions.
Reproduce:
- Connect a second monitor (to your Mac)
- Move QCreator to the second monitor
- Compile and run the code below
#include <QWidget>
#include <QApplication>
#include <QDebug>
#include <QWindow>
#include <QScreen>
#include <QDesktopWidget>
#include <QKeyEvent>
class Widget : public QWidget
{
using Base = QWidget;
protected:
void keyPressEvent(QKeyEvent* e)
{
if(e->key() == Qt::Key_Space)
{
qDebug()<<windowHandle()->screen()->geometry()<<QApplication::desktop()->screenGeometry(this);
}
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
- Press space, the rect of the main monitor is printed first, then the correct rect from QDesktopWidget