qt4在嵌入式板子上執行時,只要在引數後面加-display "transformed:rot90"就可以旋轉90度,qt5 opengl有這個功能,但是linuxfb沒有這個功能。
qt5.4的linuxfb旋轉顯示補丁**如下: 取自 可能需要翻牆,所以直接貼**,另外這個補丁有個缺陷,觸控點會對應不上。
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())
+ 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()
qvectorrects = touched.rects();
for (int i = 0; i < rects.size(); i++)
+
+ else if( mrotation == 180 )
+
++ if( mrotation != 0 )
+
+ 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;
打完後,使用方法如下:加引數-platform linuxfb:fb=/dev/fb0:rotation=90 QT 螢幕旋轉 尺寸設定
1 與qt程式顯示文字大小有關的兩項 export qws display linuxfb mmwidth152 mmheight91 0 輸出裝置為linux framebuffer,尺寸定義 尺寸定義與文字大小有直接關係,長寬螢幕datasheet 可查 或者 直接量取,單位 為mm expor...
html5螢幕旋轉事件
可以參考這篇論壇 html5螢幕旋轉事件 測試的時候按照 media 的css可以實現相關的body顏色改變效果,其他的方法在瀏覽器中沒有測試成功,或許是沒有在手機上進行測試緣故。下面的 再手機上進行測試後,測試通過。html頁面如下 connecting to device device is r...
在qt下獲取螢幕解析度
1,在windows下可以使用 getsystemmetrics sm cxscreen getsystemmetrics sm cyscreen 獲取。2,在linux下可以使用xdisplaywidth xdisplayheight void getscreeninfo 說到這裡,順便標記以下多...