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. Qt 5 embedded screen rotation
QtWS25 Last Chance

Qt 5 embedded screen rotation

Scheduled Pinned Locked Moved Mobile and Embedded
23 Posts 19 Posters 39.1k Views
  • 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.
  • U Offline
    U Offline
    ufas
    wrote on 27 Jun 2014, 15:11 last edited by
    #9

    Same problem here. Any information is welcome, even it is a statement that this is not possible.

    Btw: is this the wrong use case? Should one use QML?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on 30 Jun 2014, 12:00 last edited by
      #10

      There is no equivalent of QWS' transforms, neither in linuxfb nor eglfs.

      Qt Quick applications are expected to do the transformations themselves.

      For widget apps this is a bit unfortunate since they are left out in the cold for now. :/

      C 1 Reply Last reply 1 Jul 2015, 17:30
      0
      • A Offline
        A Offline
        agocs
        wrote on 30 Jun 2014, 12:08 last edited by
        #11

        Created http://bugreports.qt-project.org/browse/QTBUG-39959

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kumars
          wrote on 8 Sept 2014, 15:04 last edited by
          #12

          Hello All,
          I have same problem. App works fine on Qt4 with QML 1.1 version on both landscape and portrait mode... I use transformed:Rot270.

          But in Qt5 if I try to rotate my app in QML rootitem by transform: Rotation {
          angle: 180
          origin.x: root.width / 2
          origin.y: root.height / 2
          }

          it does not work properly...only part of the screen is rotated..Any known issues in that area ?
          Thanks Kumars

          1 Reply Last reply
          0
          • 0 Offline
            0 Offline
            0xFa81
            wrote on 27 Apr 2015, 06:49 last edited by 0xFa81
            #13

            My solution was: (in mainwindow.cpp-constructor):

            QGraphicsScene *scene = new QGraphicsScene();
            QGraphicsView *view = new QGraphicsView(parent);
            view->setGeometry(0,0,X,Y); // actual Display size
            view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            QGraphicsProxyWidget *proxy = scene->addWidget(this);
            view->setScene(scene);
            view->show();
            view->rotate(90);
            
            M 1 Reply Last reply 5 May 2016, 16:22
            0
            • A agocs
              30 Jun 2014, 12:00

              There is no equivalent of QWS' transforms, neither in linuxfb nor eglfs.

              Qt Quick applications are expected to do the transformations themselves.

              For widget apps this is a bit unfortunate since they are left out in the cold for now. :/

              C Offline
              C Offline
              Chad Barbe
              wrote on 1 Jul 2015, 17:30 last edited by
              #14

              @agocs Does this mean that one cannot run a QWidget based application in portrait mode on a natively landscape display? For example, I have a 480x272 display that my hardware team wants to orient in a portrait orientation.

              I have tried a number of things including the last suggestion on this thread from 0xFa81 but i end up with garbled text. That's the best way i can explain it. When I run the same code on my development box it works fine and the text is not garbled and show up sideways on my monitor. But if i run it on my embedded device i get text where the letters are switched around.

              I started another thread about this here:

              http://forum.qt.io/topic/55907/qwidget-based-application-in-non-native-orientation-on-embedded-linux-with-fbdev-platform

              1 Reply Last reply
              0
              • R Offline
                R Offline
                ranshalit
                wrote on 18 Dec 2015, 06:16 last edited by
                #15

                Hi,

                Does Qt rotation is done as part of Qt library/application or as control to framebuffer (which in this case is expected to support rotation).
                I ask because in our HW/fbdev driver there is no support for rotation, so I wander if Qt can do this rotation in software...

                Thanks,
                Ran

                1 Reply Last reply
                0
                • 0 0xFa81
                  27 Apr 2015, 06:49

                  My solution was: (in mainwindow.cpp-constructor):

                  QGraphicsScene *scene = new QGraphicsScene();
                  QGraphicsView *view = new QGraphicsView(parent);
                  view->setGeometry(0,0,X,Y); // actual Display size
                  view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
                  view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
                  QGraphicsProxyWidget *proxy = scene->addWidget(this);
                  view->setScene(scene);
                  view->show();
                  view->rotate(90);
                  
                  M Offline
                  M Offline
                  matthew2011
                  wrote on 5 May 2016, 16:22 last edited by
                  #16

                  @0xFa81 I'm curious if this is the method you are still using.

                  I'm using this on a product I'm helping with, and the performance is rather slow and is negatively impacting product design requirements (graphing updates per second).

                  I've tried adjusting the QGraphicsView settings (optimization, etc), but no improvement.

                  If anyone has found a better way to rotate a landscape LCD to portrait, on a platform using linuxFB (all software driven, no hardware graphics cores at all) help is appreciated.

                  This platform was previously being developed in Qt4, and the QWS system rotated without any noticeable issues...

                  Thank you!

                  Matthew

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tsaG
                    wrote on 23 Jul 2016, 21:19 last edited by
                    #17

                    Are there any news about rotating the Display? I do have a Raspberry 7" Display which is landscape native. Using lcd_rotate in the boot config doesnt work (it only works for 180°) and display_rotate misses to rotate the touchscreen. So I need to either rotate the whole thing (touch and display) or just the touchscreen (then I would use the display_rotate). Is there a way to do this?

                    export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=rotate=90

                    somehow doesnt work for me (should it?)

                    thanks!

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Ajith_P_V
                      wrote on 26 Jul 2016, 05:38 last edited by Ajith_P_V
                      #18

                      Though it is a pretty old query, I think answering to this thread is still valid.
                      The major difference between Qt4.8 and Qt5.x.x is that, they removed the Qt's own windowing system and let it open for user defined windowing system. That means, QWS (Qt Windowing System) is no more part of the Qt and we can use X11, Wayland or FB as the backend for the same.
                      If someone want to rotate the screen, then basically that is doing with the help of the windowing system but not just with the Qt itself. As many other people stated, Qt4 rotation is done with the QWS.
                      If you are using X11 windowing system along with Qt5, then X11 have rotation feature and one should make use of that for the Qt rotation.
                      I hope this helps.

                      Regards,
                      Ajith P V

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tsaG
                        wrote on 31 Jul 2016, 23:31 last edited by
                        #19

                        Hi, Is this also valid for the QT embedded since it is using EGLFS? All I found was the workaround using setTransformation, but this (at least thats what it looks like) was removed in QT 5.

                        A Dr.VD 2 Replies Last reply 2 Aug 2016, 10:46
                        0
                        • T tsaG
                          31 Jul 2016, 23:31

                          Hi, Is this also valid for the QT embedded since it is using EGLFS? All I found was the workaround using setTransformation, but this (at least thats what it looks like) was removed in QT 5.

                          A Offline
                          A Offline
                          Ajith_P_V
                          wrote on 2 Aug 2016, 10:46 last edited by
                          #20

                          @tsaG Yes, you are right. "setTransformation" is part of QWSDisplay and in Qt5, they have removed the complete QWS windowing system itself. So as far as my knowledge, there is no equivalent for "setTransformation". However, instead of QWS windowing system, now Qt5 opens to any other popular windows systems such as x11 which can do this trick.
                          PS: I'm afraid I can't help you with EGLFS since, my qt work is around the corner of X11 almost all time.

                          1 Reply Last reply
                          0
                          • T tsaG
                            31 Jul 2016, 23:31

                            Hi, Is this also valid for the QT embedded since it is using EGLFS? All I found was the workaround using setTransformation, but this (at least thats what it looks like) was removed in QT 5.

                            Dr.VD Offline
                            Dr.VD Offline
                            Dr.V
                            wrote on 3 Aug 2016, 10:37 last edited by
                            #21

                            @tsaG There does not seem to be any easy way – unless you are using QML.

                            However, it is possible that your platform supports rotation. For example, Raspberry Pi (kind of) supports rotation as a boot-up option. The rotation occurs then at a lower level (i.e. below the OpenGL layer). Other embedded platforms may provide similar functionality.

                            I actually tested both methods (with RPi/EGLFS). Using the QML rotation is relatively fast, at least I did not notice any significant speed difference between landscape and portrait orientations. Using the platform-specific rotation was slow, but that result cannot be generalized to other platforms. (RPi seems to fall into some sort of soft OpenGL when rotated by 90° or 270°.)

                            Of course, X11 or Wayland may provide a solution here, but at the same time the performance will suffer both at startup and during run time. YMMV.

                            This is a strange omission indeed, as screen rotation is not uncommon with embedded devices.

                            1 Reply Last reply
                            0
                            • PederP Offline
                              PederP Offline
                              Peder
                              wrote on 10 Aug 2016, 14:28 last edited by Peder 8 Oct 2016, 20:47
                              #22

                              I found a solution that works for single touch. First I rotate the display:

                              sudo nano /boot/config.txt
                              

                              Add this at the end for a 90 degree rotation:

                              display_rotate=1
                              

                              Restart unit.

                              Then I Just catch the touch event, transforms the coordinate and then send a mouse event instead.

                              Creating a new class:

                              myguiapplication.h

                              #ifndef MYGUIAPPLICATION_H
                              #define MYGUIAPPLICATION_H
                              
                              #include <QGuiApplication>
                              #include <QEvent>
                              
                              class MyGuiApplication : public QGuiApplication
                              {
                                  Q_OBJECT
                              public:
                                  MyGuiApplication(int &argc, char **argv);
                                  virtual bool notify(QObject*, QEvent*);
                              };
                              
                              #endif // MYGUIAPPLICATION_H
                              

                              myguiapplication.c

                              #include "myguiapplication.h"
                              #include <QTouchEvent>
                              #include <QMouseEvent>
                              #include <QDebug>
                              
                              MyGuiApplication::MyGuiApplication(int &argc, char **argv) : QGuiApplication(argc, argv)
                              {
                              
                              }
                              
                              bool MyGuiApplication::notify(QObject* target, QEvent* event)
                              {
                                  try {
                                      switch (event->type())
                                      {
                                      case QEvent::TouchBegin:
                                      case QEvent::TouchUpdate:
                                      case QEvent::TouchEnd:
                                      {
                                          QTouchEvent* te = static_cast<QTouchEvent*>(event);
                              
                                          if (te->device()->type() == QTouchDevice::TouchScreen)
                                          {
                                              QList<QTouchEvent::TouchPoint> tps = te->touchPoints();
                              
                                              if(tps.count() != 1)
                                              {
                                                  qDebug() << "Touch points != 1";
                                                  return true;
                                              }
                              
                                              qreal tx = tps.first().pos().x();
                                              qreal ty = tps.first().pos().y();
                              
                                              qreal mx = 480.0/800 * ty;
                                              qreal my = 800 - 800.0/480 * tx;
                              
                                              qDebug() << tx << "," << ty << " => " << mx << "," << my;
                              
                                              QPointF mp(mx, my);
                              
                                              switch (event->type())
                                              {
                                              case QEvent::TouchBegin:
                                              {
                                                  qDebug() << "BEGIN";
                                                  QMouseEvent ee(QEvent::MouseButtonPress, mp, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                                                  QCoreApplication::sendEvent(target, &ee);
                                                  break;
                                              }
                                              case QEvent::TouchUpdate:
                                              {
                                                  qDebug() << "UPDATE";
                                                  QMouseEvent ee(QEvent::MouseMove, mp, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                                                  QCoreApplication::sendEvent(target, &ee);
                                                  break;
                                              }
                                              case QEvent::TouchEnd:
                                              {
                                                  qDebug() << "END";
                                                  QMouseEvent ee(QEvent::MouseButtonRelease, mp, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                                                  QCoreApplication::sendEvent(target, &ee);
                                                  break;
                                              }
                                              default:
                                                  qDebug() << "Unhandled touch event";
                                                  return true;
                                              }
                              
                                              return true;
                                          }
                                          break;
                                      }
                                      case QEvent::MouseButtonPress:
                                      {
                                          QMouseEvent *k = (QMouseEvent *)event;
                                          qDebug() << "MouseButtonPress:" << k->pos();
                                          break;
                                      }
                                      case QEvent::MouseMove:
                                      {
                                          QMouseEvent *k = (QMouseEvent *)event;
                                          qDebug() << "MouseMove:" << k->pos();
                                          break;
                                      }
                                      case QEvent::MouseButtonRelease:
                                      {
                                          QMouseEvent *k = (QMouseEvent *)event;
                                          qDebug() << "MouseButtonRelease:" << k->pos();
                                          break;
                                      }
                                      default:
                                          ;
                                      }
                                  } catch (...) {
                                  }
                              
                                  return QGuiApplication::notify(target, event);
                               }
                              

                              And then using my new class instead of QGuiApplication:

                              #include "myguiapplication.h"
                              #include <QQmlApplicationEngine>
                              #include <QQmlContext>
                              int main(int argc, char *argv[])
                              {
                                  MyGuiApplication app(argc, argv);
                                  //...
                              }
                              
                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                katd
                                wrote on 23 Dec 2016, 19:03 last edited by
                                #23

                                Has anyone found a suitable solution for an embedded device on eglfs? I want to use a natively portrait display in landscape orientation, for displaying Qt5 Widget applications

                                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