How to rotate screen in Qt5
-
hello everyone.I can use "-display transformed:Rot270" to rotate screen in Qt4, but it does not work in Qt5 because qws has eliminated in Qt5. So, how to rotate the screen in Qt5?
-
Take a look at QScreen and its transformBetween() function.
This will work as long as you have no desktop enviroment and just one window to show.
You can get a QScreen with QWindow::screen().... -
[quote author="jseeQt" date="1413804978"]Take a look at QScreen and its transformBetween() function.
This will work as long as you have no desktop enviroment and just one window to show.
You can get a QScreen with QWindow::screen()....[/quote]Thanks.I get a QScreen width qAp->screens(),and get a QTransform with QScreen::transformBetween.I take a look at QTransform ,this class can be used to rotate a pixmap,but how to rotate screen by this QTransform.
-
add widgets to QGraphicsScene and call QGaphicsProxyWidget::setRotation to rotate the screen.
-
QScreen *s = app.primaryScreen();
qDebug() << "nativeOrientation: " << s->nativeOrientation(); qDebug() << "orientation: " << s->orientation(); qDebug() << (s->isLandscape(s->nativeOrientation()) ? "nativeOrientation lanscape" : "nativeOrientation not lanscape"); qDebug() << (s->isLandscape(s->orientation()) ? "orientation lanscape" : "orientation not lanscape"); qDebug() << (s->isPortrait(s->nativeOrientation()) ? "nativeOrientation portrait" : "nativeOrientation not portrait"); qDebug() << (s->isPortrait(s->orientation()) ? "orientation portrait" : "orientation not portrait");