Raspberry Pi Qt5 设置物理屏幕尺寸 [英] Raspberry Pi Qt5 Set physical screen size

查看:27
本文介绍了Raspberry Pi Qt5 设置物理屏幕尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用交叉编译在 raspbian 上的 raspberry pi 上开发一个 qt5 应用程序.

I am developping a qt5 application on my raspberry pi on raspbian using cross compilation.

当我运行它时,我得到一个黑屏,试图显示一个 QFrame 弹出窗口.

When I run it, I get a black screen trying display a Pop-up which is a QFrame.

我想它无法定位,因为我在开头收到错误消息:

I suppose that it cannot be positioned because I have error messages arriving at the beginning :

EGLFS:无法查询物理屏幕尺寸,默认为 100 dpi.

EGLFS: Unable to query physical screen size, defaulting to 100 dpi.

EGLFS:要覆盖,设置 QT_QPA_EGLFS_PHYSICAL_WIDTH 和 QT_QPA_EGLFS_PHYSICAL_HEIGHT(以毫米为单位).

EGLFS: To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).

EGLFS:无法查询屏幕深度,默认为 32.

EGLFS: Unable to query screen depth, defaulting to 32.

EGLFS:要覆盖,设置 QT_QPA_EGLFS_DEPTH.

EGLFS: To override, set QT_QPA_EGLFS_DEPTH.

当我禁用 QFrame 时,应用程序默认全屏启动,而我没有设置它.

When I disable the QFrame, the application is launched in full-screen by default, whereas I didn't set it.

我尝试使用以下命令设置这些环境变量:

I tried to set these environment variables with :

int main(int argc, char *argv[])
{
    QByteArray width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH");
    width.setNum(1920);

    QByteArray height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
    height.setNum(1080);

    QApplication a(argc, argv);

    MainWindow w;
    w.show();
    w.launchGame();

    return a.exec();
}

但错误信息仍然显示.

主窗口是一个 QWidget,我使用 :

The main window is a QWidget and I defined his size using :

setFixedSize(1280, 720);

我的问题是,如何正确设置这些变量或者您有其他解决方案吗?

My question is, how to set these variables correctly or do you have another solution ?

推荐答案

Raspberry Pi 3 Kernel 4.14.27-v7+

Raspberry Pi 3 Kernel 4.14.27-v7+

从 Ubuntu 16.04 主机交叉编译的 Qt 5.10.1

Qt 5.10.1 cross-compiled from Ubuntu 16.04 host

我必须将以下内容添加到我的 Rpi 上的 .profile

I had to add the following to my .profile on my Rpi

打开.profile

sudo nano ~/.profile

我在最后添加了这些行

# physical display properties
export QT_QPA_EGLFS_PHYSICAL_WIDTH=520
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=326

然后使用(或重新启动)重新加载 bash 配置文件

Then reload bash profile with (or reboot)

source .profile

以下链接包含所有 EGLFS 环境变量的说明:

The following link has descriptions for all the EGLFS environment variables:

http://doc.qt.io/qt-5/embedded-linux.html

这篇关于Raspberry Pi Qt5 设置物理屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆