平台无关的图形用户界面

发布于 2024-11-08 01:52:33 字数 141 浏览 0 评论 0原文

我想为我的应用程序制作 GUI。它应该可以在多个平台上运行。我希望大部分代码对于所有操作系统(unix、windows、MAC)都是可移植的。

GTK 和 GLib 看起来是一个很好的解决方案。我也想使用本机 API

如何做到这一切?

I want to make GUI for my application. It should work on multiple platforms. I want most of the code to be portable for all the OS (unix, windows, MAC).

GTK and GLib looks as a good solution. I want to use native APIs too

How to do this all??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

凡尘雨 2024-11-15 01:52:33

Qt 可能对此有好处。

Qt may be good for that.

因为看清所以看轻 2024-11-15 01:52:33

我喜欢 WxWidgets,真的很容易使用。它具有多种语言的绑定,您可以轻松地将其 C++ 实现与 Win32 API(C 代码)混合。

http://www.wxwidgets.org/

更轻量级的替代方案是 FLTK

http://www.fltk.org/index.php

I like WxWidgets, really easy to use. It has bindings for multiple languages and you can mix it's C++ implementation with Win32 API (C code) easily.

http://www.wxwidgets.org/

A more lightweight alternative is FLTK

http://www.fltk.org/index.php

你列表最软的妹 2024-11-15 01:52:33

您必须实现PAL平台抽象层)。
该层应该通过提供不依赖于平台的接口来提供对实际平台调用的抽象。一旦转移到另一个平台,只需为该特定平台实现 PAL,应用程序的其余部分可以按原样使用。

You will have to implement a PAL(Platform abstraction layer).
This layer should provide a abstraction over the actual platform calls by providing interfaces which are not platform dependednt. Once you move on to another platform, only the PAL needs to be implemented for that particular platform and the rest of the application can be used as is.

壹場煙雨 2024-11-15 01:52:33

Qt 似乎是一个选择。但如果你想使用Windows API,它就不是可移植的。 Windows 中的 Qt 会使用 CreateWindow 等东西,但你不会。例如,反汇编器 IDA 最近用 Qt 重写,现在是跨平台的。

Qt seems like an option. But if you want to use Windows API's, it will not be portable. Qt in Windows will use stuff like CreateWindow etc. but you will not. E.g. the disassembler IDA was recently rewritten in Qt and is now cross-platform.

东走西顾 2024-11-15 01:52:33

我认为学习您所针对的每个平台上的本机窗口层是值得的。

因此:

  • Coco
    Cocoa 是原生 Mac OS X 窗口层。它是一个 Objective-C api,但学习起来并不难,而且很容易与 C 或 C++ 进行互操作。
  • Win32 API
    Windows API 是一个实现 Windows 本机小部件集的 C API。
  • GTK+
    Unix/Linux 世界更加复杂,因为它可能针对完全不同的小部件集实现编写应用程序。您需要选择目标环境默认桌面使用的小部件集:如果您的目标是 Ubuntu,则 GTK+ (2) 是用于访问 Unity 桌面“本机”小部件集的 API。

我个人不喜欢 QT,因为他们发明了自己的元编译器,这使得 QT 代码(讽刺的是)很难移植到非 QT 环境。然而,QT 确实在可能的情况下呈现了本机 Widget 集的抽象。

wxWidgets 是一个方便使用的包装 API,因为它已经在相关平台上包装了 Win32Api、Cocoa api 和 GTK+。然而,我避免使用它,因为 Wx 基于 Microsoft MFC - 一个有点过时的文档/视图 C++ 框架,我想了解底层平台。


  • 对 QT 进行了一些更正。

I Think its worthwhile learning the native windowing layer on each platform you are targetting.

As such:

  • Cocoa
    Cocoa is the native Mac OS X windowing layer. Its an Objective-C api, but its not hard to learn, and its easy to interop with either C or C++.
  • Win32 API
    The Windows API is a C API that implements the windows native widget set.
  • GTK+
    The Unix/Linux world is more complicated as its possible to have apps written against completely different widget set implementations. You need to choose the widget set used by your target environments default desktop: If you are targeting Ubuntu then GTK+ (2) is the API to target to access the Unity desktops "native" widget set.

I don't personally like QT as they've invented their own meta compiler, making QT code (ironically) hard to port to non QT environments. QT does however present an abstraction of the native Widget set where possible.

wxWidgets is a convenient wrapper API to use as it already wraps the Win32Api, Cocoa api and GTK+ on the relevant platforms. I avoided using it however as Wx is based on Microsoft MFC - a somewhat dated Document/View C++ framework and I wanted to understand the underlying platforms.


  • Edited with some corrections wrt QT.
╰ゝ天使的微笑 2024-11-15 01:52:33

请看一下 Qt 框架。这将帮助您创建跨平台 GUI 应用程序。您必须依赖 Qt 提供的 API 来执行本机平台任务,否则,如果您继续使用本机 API,您的代码将无法移植。

Please take a look at Qt Framework. This will help you create cross platform GUI Applications. You would have to rely on API Offered by Qt for Native platform tasks, other wise if you proceed to use the native API's your code will not be portable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文