如何使用Linux FrameBuffer旋转Qt5应用程序? [英] How to rotate a Qt5 application using the linux framebuffer?

查看:98
本文介绍了如何使用Linux FrameBuffer旋转Qt5应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个直接在linux帧缓冲区(没有x-Windows)上运行的嵌入式linux应用程序.现在,我们必须将显示器物理旋转180度.如何使我的Qt应用程序旋转以使其不会上下颠倒?我看到了使用以下选项的参考:

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.

在Ubuntu服务器16.04.6上使用Qt 5.9.2

Using Qt 5.9.2 on Ubuntu server 16.04.6

推荐答案

您可以在应用程序级别进行处理.使用QML很简单,但是使用QWidgets时,我能想到的最好的办法是在 QGraphicsScene 上呈现Widget并像这样旋转它:

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.

我还认为正确的语法是 -platform linuxfb:fb =/dev/fb0:rotation = 180 注意 = 而不是:,但这对我也没有影响.

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

这篇关于如何使用Linux FrameBuffer旋转Qt5应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆