问题
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