Qt embedded screen rotation inside app

99封情书 提交于 2019-12-14 03:39:28

问题


In our target device, we run our QtE app with -qws argument. To rotate the screen, we specify "-display transformed:rot90" as the app argument and it works well.

However, we have a feature to rotate screen inside the app, so we try below API documented in QScreen:

QWSDisplay::setTransformation(QTransformedScreen::Rot90, 0);

But this API doesn't work at all. It's no error message in the console output.

Does anyone know what's going on about this API? Do we need to enable something else?


回答1:


Contrary to other qt documentation, documentation for the embedded part of qt is indeed poor. After few days of fiddling with it, I finally managed to solve it.

First thing to do is to compile the library with -qt-gfx-transformed option (along with whatever you need).

Then you compile your application, and start it with the option you already used to activate the transformation driver. I actually started like this :

export QWS_DISPLAY=Transformed:Rot90:0
./app

As a test, I implemented this, to test whether the rotation works :

class X : public QObject
{
  Q_OBJECT
public :
  X() :
    QObject()
  {
    QTimer *t = new QTimer( this );
    connect( t, SIGNAL(timeout()), this, SLOT(OnTimerEvent()));
    t->start( 2500 );
  }

public slots :
  inline void OnTimerEvent()
  {
    static int v = 0;
    ++v;

    QWSDisplay::setTransformation(v%4);

    std::cout<<v<<std::endl;
  }
};

So, in the timer slot, I am changing the orientation with QWSDisplay::setTransformation function.



来源:https://stackoverflow.com/questions/21899586/qt-embedded-screen-rotation-inside-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!