Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to detect Rotate on Android?

How to detect Rotate on Android?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hamlet
    wrote on last edited by
    #1

    Hi,
    I want to detect rotate on Android.

    on MainWindow::MainWindow(QWidget *parent),
    I use QScreen event: orientationChanged

    QScreen *s = QGuiApplication::primaryScreen();
        connect(s, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
                   this, SIGNAL(orientationChanged(Qt::ScreenOrientation)));
    
         s->setOrientationUpdateMask(
                    Qt::PortraitOrientation
                    | Qt::LandscapeOrientation
                    | Qt::InvertedPortraitOrientation
                    | Qt::InvertedLandscapeOrientation);
    
    void MainWindow::orientationChanged(Qt::ScreenOrientation orientation)
    {
        qDebug() << "Orientation:" << orientation;
    }
    

    in header:

    public slots:
    void orientationChanged(Qt::ScreenOrientation orientation);
    

    but the event orientationChanged not fire.
    How do I get event when Android rotate?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Take a closer look at your code:

      connect(s, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
                     this, SIGNAL(orientationChanged(Qt::ScreenOrientation)));
      

      You use SIGNAL where you actually should use SLOT.
      Change it to:

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • H Offline
        H Offline
        Hamlet
        wrote on last edited by
        #3

        Thanks Jsulm,
        That's my typo

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved