From 2c0ad5af2a65a9a08c1eeb420e4a08da95dbe4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Dillau?= Date: Tue, 30 Nov 2021 23:28:35 +0100 Subject: [PATCH] Time hack on orientation change --- mainwindow.cpp | 19 ++++++++++++++++++- mainwindow.h | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a266b58..04cb4aa 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -51,10 +51,14 @@ #include "chip.h" #include "mainwindow.h" #include "view.h" - #include #include +#include +#include +#include +#include + MainWindow::MainWindow(QWidget *parent) : QWidget(parent), scene(new QGraphicsScene(this)) , h1Splitter(new QSplitter(this)), h2Splitter(new QSplitter(this)) @@ -87,6 +91,19 @@ MainWindow::MainWindow(QWidget *parent) setLayout(layout); setWindowTitle(tr("Chip Example")); + + m_screen = QGuiApplication::primaryScreen(); + qDebug() << "Available geo: " << m_screen->availableGeometry() ; + + connect(m_screen, &QScreen::orientationChanged, + this, &MainWindow::onOrientationChanged); +} + +// HACK +void MainWindow::onOrientationChanged(Qt::ScreenOrientation orientation) +{ + Q_UNUSED(orientation); + QThread::msleep(10); } void MainWindow::populateScene() diff --git a/mainwindow.h b/mainwindow.h index ff1bb35..ee5d918 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -52,6 +52,7 @@ #define MAINWINDOW_H #include +#include QT_BEGIN_NAMESPACE class QGraphicsScene; @@ -64,6 +65,9 @@ class MainWindow : public QWidget public: MainWindow(QWidget *parent = nullptr); +protected slots: + void onOrientationChanged(Qt::ScreenOrientation orientation); + private: void setupMatrix(); void populateScene(); @@ -71,6 +75,8 @@ private: QGraphicsScene *scene; QSplitter *h1Splitter; QSplitter *h2Splitter; + + QScreen *m_screen; }; #endif // MAINWINDOW_H -- 2.30.1 (Apple Git-130)