与它们与 Windows 和 OS X 的集成方式相比,GTK 和 Qt 与 Linux 的集成方式如何? [英] How do GTK and Qt integrate with Linux in comparison to how they integrate with Windows and OS X?

查看:26
本文介绍了与它们与 Windows 和 OS X 的集成方式相比,GTK 和 Qt 与 Linux 的集成方式如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,Windows 和 OS X 端的 Qt 和 GTK 只是原生 GUI 库的包装器,例如 OS X 包装 Cocoa,Windows 包装 Win32.但是,我的问题是,它们如何与 Linux 集成?桌面环境开发人员是否必须为 Qt 或 GTK 实现特殊的库,或者它是如何工作的?我环顾四周,但我真的找不到答案.

From my understanding, Qt and GTK on the Windows and OS X side are just wrappers around the native GUI libraries, like for OS X it wraps around Cocoa, and for Windows around Win32. However, my question is, how do they integrate with Linux? Do the Desktop Environment developers have to implement special libraries for either Qt or GTK or how does it work? I have looked around but I can't really find the answer.

推荐答案

在 Linux(台式机和笔记本电脑)上,图形屏幕通常由 X11 服务器.您的 GUI 应用程序通过 sockets 与该服务器通信,通常在本地Unix socket/tmp/.X11-unix/X0.X11 服务器通常是 Xorg.

On Linux (desktops and laptops) the graphical screen is generally displayed (at least that was the case in beginning of 2015) by the X11 server. Your GUI app is communicating with that server thru sockets, often locally on a Unix socket like /tmp/.X11-unix/X0. The X11 server is generally Xorg.

对于一些嵌入式设备,如 Android 手机或一些小工具(汽车、汽车或医疗设备行业中的 GPS),情况有所不同(DirectFB, 帧缓冲设备 -由桌面上的 X11 服务器使用,...)

For some embedded devices like Android mobile phones or some gadgets (GPS in cars, automotive or medical device industry) it is different (DirectFB, framebuffer devices -which is used by the X11 server on your desktop, ...)

某些发行版正在切换到 Wayland(或者可能切换到 Mir).由于我对这些了解不多,无法解释其中的血腥细节.AFAIU,仍然涉及一些服务器(与 Xorg 一样,它是唯一与您的显卡通信的用户端软件组件)和一些协议,以及 Qt & 等主要工具包.GTK 已经适应了它们(因此,如果您为 Qt 或 GTK 编写代码,您不必关心这些细节,但您应该升级您的工具包).

Some distributions are switching to Wayland (or perhaps to Mir). Since I don't know these much, I cannot explain the gory details. AFAIU, there is still some server involved (which, like Xorg, is the only user-land software component talking to your graphics card) and some protocol, and major toolkits like Qt & GTK are been adapted to them (so if you code for Qt or for GTK, you don't care about those details, but you should upgrade your toolkit).

图形工具包(Qt、Gtk)通过一些特定的协议与 X11 服务器(或 Wayland 服务器)交互,例如用于 X11 的 X Window 系统协议.由于历史原因,这些协议相当复杂,实际上需要遵循一些约定,例如 EWMH.

The graphical toolkits (Qt, Gtk) are interacting with the X11 server (or the Wayland one) thru some specific protocol(s), e.g. X Window System protocols for X11. For historical reasons, these protocols are quite complex, and practically require to follow some conventions like EWMH.

另请参阅相关问题的此答案.我在那里解释说 X11 在今天不像在上个世纪那样被使用;特别是服务器端X11 的绘图能力(例如 Xlib 的 XDrawLineXDrawText) 今天很少使用,因为工具包是绘制像素图图像客户端并发送到服务器.

See also this answer to a related question. I explain there that X11 is not used today as it was in the previous century; in particular the server-side drawing abilities of X11 (e.g. Xlib's XDrawLine or XDrawText) are rarely used today, because the toolkit is drawing a pixmap image client side and sending it to the server.

请注意,您可能会考虑不提供 GUI 界面,而是提供 Web 界面,以便您的应用程序(例如使用像 libonionWt, ....);那么您的应用程序将成为一个专门的 Web 服务器,用户将通过他的浏览器(在他的台式机/笔记本电脑/平板电脑/手机中)与您的应用程序进行交互.

Notice that you might consider giving not a GUI interface, but a Web interface, to your application (e.g. using libraries like libonion, Wt, ....); then your application becomes a specialized Web server, and the user would go thru his browser (in his desktop/laptop/tablet/phone) to interact with your app.

实际上,用户界面非常复杂,您真的应该为它们使用一些工具包(Qt 如果使用 C++ 编码).从头开始编码(甚至高于 XlibXCB for X11) 需要多年的工作.

Practically speaking, user interfaces are so complex that you really should use some toolkit for them (Qt if coding in C++). Coding from scratch (even above Xlib or XCB for X11) would requires years of work.

在 X11 之上还有其他几个 widget 工具包,例如FOX 工具包FLTK(但它们中的大多数功能比 Qt 或 GTK 少得多).

There exist several other widget toolkits above X11, e.g. FOX toolkit, FLTK (but most of them have much less features than Qt or GTK).

这篇关于与它们与 Windows 和 OS X 的集成方式相比,GTK 和 Qt 与 Linux 的集成方式如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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