6

I have an embedded linux application running directly on the linux framebuffer (no x-Windows). We now have to physically rotate the display 180 degrees. How do I get my Qt application to rotate so it doesn't appear upside down? I saw reference to using the following option:

 -platform linuxfb:fb=/dev/fb0:rotation:180 

However, the rotation option seems to be ignored.

Using Qt 5.9.2 on Ubuntu server 16.04.6

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
KyleL
  • 1,379
  • 2
  • 13
  • 35

1 Answers1

4

You could handle it on application level. With QML thats easy, but with QWidgets the best I could come up with is to render the Widget on a QGraphicsScene and rotate it like this:

#include "mainwindow.h"
#include <QApplication>

#include <QGraphicsScene>
#include <QGraphicsView>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *view = new QGraphicsView();
    view->setGeometry(w.geometry());
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scene->addWidget(&w);
    view->setScene(scene);
    view->show();
    view->rotate(180);

    //w.show();

    return a.exec();
}

It seems a bit glitchy, but you could give it a try.

Also I think the correct syntax is -platform linuxfb:fb=/dev/fb0:rotation=180 note the = instead of : Edit: but that did not make a difference for me either.

Rick Pat
  • 789
  • 5
  • 14
  • 1
    This appears to do what I need, thanks! Also, the rotation=180 vs rotation:180 made no difference. It still seems like there should be a simpler method than using the QGraphicsScene, but I will go with what works. – KyleL Jun 19 '19 at 18:12