QT5显示的graphics介绍

这部分直接看qt对嵌入式的支持介绍,不得不说,一个软件要做好,各方面都要涉及到,不懂理论的人怎么能够选择嵌入式最恰当的东西呢 —— [ Qt for Embedded Linux ]

EGLFS


EGL is an interface between OpenGL and the native windowing system. Qt can use EGL for context and surface management, however the API contains no platform-specifics: The creation of a native window (which will not necessarily be an actual window on the screen) must still be done by platform-specific means. Hence the need for the board or GPU-specific adaptation code. Such adaptations are provided either as eglfs hooks, which can be a single source file compiled into the platform plugin, or as dynamically loaded EGL device integration plugins.

EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). In addition to Qt Quick 2 and native OpenGL applications, it supports software-rendered windows (for example QWidget) too. In the latter case the widgets’ contents are rendered using the CPU into images, which are then uploaded into textures and composited by the plugin.

This is the recommended plugin for modern Embedded Linux devices that include a GPU.(介绍的比较多,这里画个重点,意思是嵌入式设备,带GPU的最好用这个)

EGLFS forces the first top-level window (be it either a QWidget or a QQuickView) to become fullscreen. This window is also chosen to be the root widget window into which all other top-level widgets (for example dialogs, popup menus or combobox dropdowns) are composited. This is necessary because with EGLFS there is always exactly one native window and EGL window surface, and these belong to the widget or window that is created first. This approach works well when there is a main window that exists for the entire lifetime of the application and all other widgets are either non top-levels or are created afterwards, once the main window is shown.

There are further restrictions for OpenGL-based windows. As of Qt 5.3, eglfs supports a single fullscreen GL window (for example, an OpenGL-based QWindow, a QQuickView or a QGLWidget). Opening additional OpenGL windows or mixing such windows with QWidget-based content is not supported and terminates the application with an error message.

XCB


This is the X11 plugin used on regular desktop Linux platforms. In some embedded environments, that provide X and the necessary development files for xcb, this plugin functions just like it does on a regular PC desktop.

Note: On some devices there is no EGL and OpenGL support available under X because the EGL implementation is not compatible with Xlib. In this case the XCB plugin is built without EGL support, meaning that Qt Quick 2 or other OpenGL-based applications does not work with this platform plugin. It can still be used however to run software-rendered applications (based on QWidget for example).

As a general rule, the usage of XCB on embedded devices is not advisable. Plugins like eglfs are likely to provide better performance, and hardware acceleration.(重点就是这个了,嵌入式不推荐

Wayland


Wayland is a light-weight windowing system; or more precisely, it is a protocol for clients to talk to a display server.

The Qt Wayland module provides a wayland platform plugin that allows Qt application to connect to a Wayland compositor.

Note: You may experience issues with touch screen input while using the Weston reference compositor. Refer to the Qt Wiki for further information.

在 Qt 的 Graphics View 框架中,图像的坐标通常使用 QGraphicsScene 和 QGraphicsItem 来表示。QGraphicsScene 是一个可以被视为一个二维平面的容器,而 QGraphicsItem 则是这个平面上的一个元素,可以是一个矩形、椭圆、多边形等等。 在 QGraphicsItem 中,图像的位置可以通过设置其坐标(x 和 y 坐标)来实现。在 QGraphicsScene 中,可以使用 QGraphicsScene::addItem() 方法将 QGraphicsItem 添加到场景中,并且可以通过 QGraphicsScene::setSceneRect() 方法来设置场景的大小和位置。 当图像在 QGraphicsView 中显示时,它们的坐标将被转换为视口坐标系。视口坐标系是 QGraphicsView 中用于显示图像的坐标系,其原点为视口的左上角,x 轴向右延伸,y 轴向下延伸。可以使用 QGraphicsView::mapToScene() 和 QGraphicsView::mapFromScene() 方法将视口坐标系与场景坐标系相互转换。 例如,以下代码片段将一张图片加载到 QGraphicsScene 中,并将其在 QGraphicsView 中居中显示: ```cpp QImage image("example.png"); QGraphicsScene* scene = new QGraphicsScene(); QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(image)); scene->addItem(item); scene->setSceneRect(QRectF(image.rect())); QGraphicsView* view = new QGraphicsView(scene); view->setAlignment(Qt::AlignCenter); view->show(); ``` 在这个例子中,图像的位置使用 QGraphicsPixmapItem 的坐标属性进行设置,而场景的大小则使用图像的大小进行设置。最后,将 QGraphicsView 的对齐方式设置为居中,并且显示视图。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值