1、用Buildroot选择qt对应模块编译,有些控件用不了,报段错误。比如:TabView、Switch、虚拟键盘等等。
2、后面通过看Linux环境下arm开发指南,书中没有用buildroot去编译qt模块,而是交叉编译qt,然后将qt放到arm板下
3、执行以下命令,使能qt环境变量。
export QTDIR=/opt/arm_qt5.15.8_aarch64
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH$QTDIR:$QTDIR/lib
export QT_QPA_PLATFORM=wayland
4、由于当前屏幕是竖屏,需要旋转屏幕。刚开始用buildroot编译后,可以用eglfs平台,然后用的以下代码旋转平台,后面遇到了第一点说的有些控件用不了,所以放弃了。
main.cpp
#ifdef PLATFORM_ARM
view.rootObject()->setProperty("rotateScreen", false);
view.showFullScreen();
#else
view.rootObject()->setProperty("rotateScreen", false);
view.show();
#endif
// 用于arm平台翻转屏幕
property bool rotateScreen: true
transform: [
Translate {
x: rotateScreen ? window.height : 0
},
Rotation {
origin.x: rotateScreen ? window.height : 0
angle: rotateScreen ? 90 : 0
}
]
接着用linuxfb平台,可以正常运行起来,但是虚拟键盘仍然是竖屏模式,所以也放弃了这个平台。
RK3326默认选择wayland平台,所以最后只能在这个平台上下功夫,第一个坑,wayland需要weston支持,但是运行weston后,会出现默认桌面应用。需要将/etc/xdg/weston/weston.ini.d目录下的ini文件移走或者删掉。第二个坑,wayland启动后有状态栏和背景,需要在/etc/xdg/weston/目录下的weston.ini执行以下指令
[shell]
panel-position=none
background-color=0x00FFFFFF
第三个坑,需要旋转屏幕方向,当前代码是旋转所有屏幕,rk的说明文档里有说旋转某个特定屏幕,但是我试了,没用,估计是名称有问题。
echo "output:all:rotate270" > /tmp/.weston_drm.conf
第四个坑,在启动脚本/etc/init.d/rcS里执行qt程序,结果显示Could not open egl display,但是手动执行又可以,是由于执行当前脚本的时候,环境变量还未设置,所有在执行程序前source /etc/profile后就可以。

第五个坑,wayland的程序是有窗口的,也就是有标题栏,去除标题栏只需要view.showFullScreen();
#include <QGuiApplication>
#include <QQmlContext>
#include <QFontDatabase>
#include <QQuickView>
#include <QQuickItem>
#include "qmlregister.h"
#include "globalsetting.h"
#include "msgqueue.h"
#include "otaupdate.h"
#include "wifimanage.h"
#include "t_smartwrapper.h"
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
// 添加字体
int fontId = QFontDatabase::addApplicationFont(":/fonts/Ubuntu-R.ttf");
QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(fontId);
if (!loadedFontFamilies.empty())
{
QFont font = loadedFontFamilies.at(0);
app.setFont(font);
}
QmlRegister qmlRegister;
qmlRegister.init();
MsgQueue *msgQueue = MsgQueue::getInstance();
WifiModel *wifiModel = WifiModel::getInstance();
GlobalSetting *globalSetting = GlobalSetting::getInstance();
T_SmartWrapper::getInstance();
OtaUpdate *otaUpgrade = OtaUpdate::getInstance();
const QUrl url(QStringLiteral("qrc:/main.qml"));
QQuickView view;
view.rootContext()->setContextProperty("MsgQueue", msgQueue);
view.rootContext()->setContextProperty("wifiModel", wifiModel);
view.rootContext()->setContextProperty("GlobalSetting", globalSetting);
view.rootContext()->setContextProperty("Ota", otaUpgrade);
view.setSource(url);
view.resize(view.rootObject()->width(), view.rootObject()->height());
#ifdef PLATFORM_ARM
view.rootObject()->setProperty("rotateScreen", false);
view.showFullScreen();
#else
view.rootObject()->setProperty("rotateScreen", false);
view.show();
#endif
return app.exec();
}
就可以让当前程序占据整个屏幕
第六个坑,字体显示异常,这块需要把Ubuntu上/usr/share/fonts下的字体打包到板子/usr/share/fonts里,可以解决中文,外语,特殊符号等字体问题。

第七个问题,开机logo到UI显示之间存在短暂切换黑屏,如需防止黑屏,可以通过下面的方式短暂冻结weston屏幕内容
- cd $$SDK /buildroot/output/rockchip_rk3326_64/target/etc/init.d目录下,打开S49weston文件

- 改动红框里的内容

目前是遇到这些问题,后面得好好研究下为啥buildroot不行的问题。
1068




被折叠的 条评论
为什么被折叠?



