[Android-development] orientationChanged() not propagated on Android.

Wiktor Grębla greblus at gmail.com
Fri Jun 24 11:40:06 CEST 2016


Hi guys.

I've been trying to use orientationChanged signal to react on orientation
changes but somehow can't get it to work.

I've seen some old threads with similar reports (Qt-5.3) but I'm more keen
to believe that I'm doing something wrong rather than it's not working.

I've tried it on Qt-5.6 and now on Qt-5.7:

#include "mainwindow.h"

#include "ui_mainwindow.h"

#include <QScreen>


MainWindow::MainWindow(QWidget *parent) :

    QMainWindow(parent),

    ui(new Ui::MainWindow)

{

    ui->setupUi(this);

    QScreen * screen = QGuiApplication::primaryScreen();

    connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
this, SLOT(onRotate(Qt::ScreenOrientation)));

    screen->setOrientationUpdateMask(Qt::PortraitOrientation|
Qt::LandscapeOrientation| Qt::InvertedPortraitOrientation|
Qt::InvertedLandscapeOrientation);

}


void MainWindow::onRotate(Qt::ScreenOrientation)

{

    ui->label->setText("Rotated!");

}


MainWindow::~MainWindow()

{

    delete ui;

}


I'll be grateful for any hints or suggestions.


Cheers,

W.


-- 
Talkers are no good doers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20160624/3cb7da86/attachment.html>


More information about the Android-development mailing list