QT官方交叉编译教程
https://wiki.qt.io/Building_Qt_for_Embedded_Linux
QT源码下载地址
https://download.qt.io/official_releases/qt/
https://download.qt.io/archive/qt/
QT4旋转
QT4在使用QWS_DISPLAY
宏设置旋转的需要在编译的时候开启-qt-gfx-transformed
选项。通过QWS_DISPLAY
宏定义设置旋转角度
export QWS_DISPLAY='Transformed:Rot270'
QT5的旋转
QT5舍弃了QWS_DISPLAY
宏。需要支持旋转需要打上path
参考博文
qt5.4_linuxfb_rotation.patch
diff --git a/src.orig/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index a66c9fa..a5b5f13 100644
--- a/src.orig/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -290,7 +290,7 @@ static void blankScreen(int fd, bool on)
}
QLinuxFbScreen::QLinuxFbScreen(const QStringList &args)
- : mArgs(args), mFbFd(-1), mBlitter(0)
+ : mArgs(args), mFbFd(-1), mBlitter(0), mRotation(90)
{
}
@@ -316,6 +316,7 @@ bool QLinuxFbScreen::initialize()
QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)"));
QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)"));
+ QRegularExpression rotationRx(QLatin1String("rotation=(0|90|180|270)"));
QString fbDevice, ttyDevice;
QSize userMmSize;
@@ -337,6 +338,8 @@ bool QLinuxFbScreen::initialize()
ttyDevice = match.captured(1);
else if (arg.contains(fbRx, &match))
fbDevice = match.captured(1);
+ else if (arg.contains(rotationRx, &match))
+ mRotation = match.captured(1).toInt();
}
if (fbDevice.isEmpty()) {
@@ -375,9 +378,17 @@ bool QLinuxFbScreen::initialize()
mDepth = determineDepth(vinfo);
mBytesPerLine = finfo.line_length;
QRect geometry = determineGeometry(vinfo, userGeometry);
+ QRect originalGeometry = geometry;
+ if( mRotation == 90 || mRotation == 270 )
+ {
+ int tmp = geometry.width();
+ geometry.setWidth(geometry.height());
+ geometry.setHeight(tmp);
+ }
+
mGeometry = QRect(QPoint(0, 0), geometry.size());
mFormat = determineFormat(vinfo, mDepth);
- mPhysicalSize = determinePhysicalSize(vinfo, userMmSize, geometry.size());
+ mPhysicalSize = determinePhysicalSize(vinfo, userMmSize, originalGeometry.size());
// mmap the framebuffer
mMmap.size = finfo.smem_len;
@@ -387,11 +398,11 @@ bool QLinuxFbScreen::initialize()
return false;
}
- mMmap.offset = geometry.y() * mBytesPerLine + geometry.x() * mDepth / 8;
+ mMmap.offset = originalGeometry.y() * mBytesPerLine + originalGeometry.x() * mDepth / 8;
mMmap.data = data + mMmap.offset;
QFbScreen::initializeCompositor();
- mFbScreenImage = QImage(mMmap.data, geometry.width(), geometry.height(), mBytesPerLine, mFormat);
+ mFbScreenImage = QImage(mMmap.data, originalGeometry.width(), originalGeometry.height(), mBytesPerLine, mFormat);
QByteArray hideCursorVal = qgetenv("QT_QPA_FB_HIDECURSOR");
#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)
@@ -436,7 +447,26 @@ QRegion QLinuxFbScreen::doRedraw()
QVector<QRect> rects = touched.rects();
for (int i = 0; i < rects.size(); i++)
+ {
+ if( mRotation == 90 || mRotation == 270 )
+ {
+ mBlitter->translate(mGeometry.height()/2, mGeometry.width()/2);
+ }
+ else if( mRotation == 180 )
+ {
+ mBlitter->translate(mGeometry.width()/2, mGeometry.height()/2);
+ }
+
+ if( mRotation != 0 )
+ {
+ mBlitter->rotate(mRotation);
+ mBlitter->translate(-mGeometry.width()/2, -mGeometry.height()/2);
+ }
+
mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
+
+ mBlitter->resetTransform();
+ }
return touched;
}
diff --git a/src.orig/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
index 1997d46..a34414f 100644
--- a/src.orig/plugins/platforms/linuxfb/qlinuxfbscreen.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h
@@ -57,6 +57,7 @@ private:
QStringList mArgs;
int mFbFd;
int mTtyFd;
+ int mRotation;
QImage mFbScreenImage;
int mBytesPerLine;
打开qt调试
export QT_DEBUG_PLUGINS=1
设置platforms路径
export QT_QPA_PLATFORM_PLUGIN_PATH=/data/platforms/
qt和tslib的环境变量
export EDITOR='/bin/vi'
export HOME='/root'
export LD_LIBRARY_PATH='/data/eeasy/plugins/qtopialmigrate/:/data/eeasy/qt_plugins/imageformats/:/data/eeasy/lib:/root/tslib/build/lib:/data/eeasy/lib:/data/lib::/data/eeasy/lib/'
export LOGNAME='root'
export OLDPWD='/data'
export PATH='/data/eeasy/bin:/bin:/sbin:/usr/bin:/usr/sbin'
export PS1='# '
export PWD='/mnt'
export QTDIR='/data/qt4.8.6/'
export QT_DEBUG_LUGINS='1'
export QT_DEBUG_PLUGINS='1'
export QT_QPA_PLATFORM='linuxfb:fb=/dev/fb0:size=720x1280:mmSize=720x1280:offset=0x0:tty=/dev/tty0'
export QT_QPA_PLATFORM_PLUGIN_PATH='/data/eeasy/plugins'
export QT_QWS_FONTDIR='/usr/local/arm/qt4.8.6/lib/fonts/'
export QWS_KEYBOARD='TTY:/dev/tty1'
export QWS_DISPLAY='Transformed:Rot270'
export QWS_MOUSE_PROTO='Tslib:/dev/input/event0 IntelliMouse:/dev/input/event2'
export SHELL='/bin/sh'
export SHLVL='1'
export TERM='vt100'
export TSLIB_CALIBFILE='/etc/pointercal'
export TSLIB_CONFFILE='/data/qt4.8.6/lib/etc/ts.conf'
export TSLIB_CONSOLEDEVICE='none'
export TSLIB_FBDEVICE='/dev/fb0'
export TSLIB_PLUGINDIR='/data/qt4.8.6/lib/ts/'
export TSLIB_ROOT='/data/qt4.8.6/'
export TSLIB_TSDEVICE='/dev/input/event1'
export TSLIB_TSEVENTTYPE='H3600'