我使用yocto为TexasInstructions DRA7XX-EVM板交叉编译了Qt5.4.8。以下是我的配置选项。
QT_CONFIG_FLAGS =
-rpath
-pkg-config
-opengl es2
-no-accessibility
-dbus
-no-directfb
-evdev
-make examples
-compile-examples
-no-fontconfig
-freetype
-no-iconv
-icu
-system-libjpeg
-system-libpng
-make libs
-eglfs
-kms
-linuxfb
-no-mitshm
-no-mtdev -no-nis -openssl-linked -no-openvg -qt-pcre -pulseaudio -release -no-sm -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds -nomake tests -make tools -no-tslib -libudev -widgets -no-xcb -no-xcursor -no-xfixes -no-xinerama -no-xinput -no-xinput2 -no-xkb -no-xkbcommon -no-xrandr -no-xrender -no-xshape -no-xsync -no-xvideo -system-zlib
-no-wayland
-force-pkg-config
我已经在我的目标外壳上导出了以下变量:
export QT_QPA_PLATFORM=linuxfb
export QT_QPA_GENERIC_PLUGINS=evdevtouch,evdevmouse,evdevkeyboard
export QT_QPA_EVDEV_KEYBOARD_PARAMETERS=grab=1
然后我运行我的应用程序:$/我的应用程序
该窗口在屏幕上显示正确。但当我退出应用程序时,屏幕不会被清除。请检查我的配置选项,并告诉我是否需要进行任何更改。还有一些关于在窗口关闭后清除帧缓冲区的解决方案。
我通过使用qAddPostRoutine()添加一个例程来解决这个问题,该例程在退出时清除帧缓冲区。
以下是清除功能:
//Used on exit to clear the fb
static void fbclear()
{
char dev[256] = "/dev/fb";
struct fb_var_screeninfo var_info;
int fd = open(dev, O_RDWR);
int line_size;
int buffer_size;
void *buffer = NULL;
if (fd < 0) {
printf("failed to open %s display devicen", dev);
return;
}
//get display size
ioctl (fd, FBIOGET_VSCREENINFO, &var_info);
line_size = var_info.xres * var_info.bits_per_pixel / 8;
buffer_size = line_size * var_info.yres;
//malloc buffer and set to 0
buffer = malloc(buffer_size);
memset(buffer, 0, buffer_size);
//write zeros to display
write(fd, buffer, buffer_size);
free(buffer);
close(fd);
return;
}
然后我在main()中添加了以下内容:
qAddPostRoutine(fbclear);
我遇到了同样的问题,并添加了以下信号处理程序,例如在main()
中定义为:CleanExit cleanExit;
来解决这个问题:
#include <csignal>
struct CleanExit{
CleanExit() {
signal(SIGINT, &CleanExit::exitQt);
signal(SIGTERM, &CleanExit::exitQt);
}
static void exitQt(int sig) {
QCoreApplication::exit(0);
}
};
好吧,我知道这是一个老问题,但对于任何正在努力解决这个问题的人来说,我可能已经找到了解决方案。
如果退出linuxfb
Qt应用程序后,您的屏幕没有重置,也没有收到输入,这意味着Qt由于某种原因未能自行重置,您必须手动执行相同的操作。为此,qfbvthandler.cpp很有用,但我做了以下操作:
- 在初始化任何Qt对象以备份当前tty的模式之前:
int k_mode = -1; // back up variable
...
int tfd = open("/dev/tty", O_RDWR);
if (tfd == -1) throw runtime_error("Cannot open TTY");
ioctl(tfd, KDGKBMODE, &k_mode);
if (k_mode == -1) throw runtime_error("Cannot recieve KDBMODE");
close(tfd);
QApplication::quit()
完成Qt未能完成的作业后:
int tfd = open("/dev/tty", O_RDWR);
if (tfd == -1) throw runtime_error("Cannot open TTY");
ioctl(tfd, KDSETMODE, KD_TEXT); // return to text mode from graphics mode
ioctl(tfd, 0x4b51, 0); // 0x4b51=KDKBMUTE, from qfbvthandler.cpp
ioctl(tfd, KDSKBMODE, k_mode); // set keyboard mode back
k_mode = -1;
const auto blink_on = "