在C ++中创建简单的跨平台GUI的最佳方法是什么?

时间:2022-09-06 00:26:02

I want to produce a desktop application with a very simple GUI (a background graphic, a cancel button and a progress bar).

我想生成一个具有非常简单的GUI(背景图形,取消按钮和进度条)的桌面应用程序。

My main targets are Mac and Windows.

我的主要目标是Mac和Windows。

Is this possible using Visual C++ 2008?

这可能使用Visual C ++ 2008吗?

Can anyone point to any examples using Visual C++?

任何人都可以使用Visual C ++指向任何示例吗?

Or is there a better way to create the GUI separately?

或者是否有更好的方法分别创建GUI?

7 个解决方案

#1


Use Qt4. http://qt-project.org/

使用Qt4。 http://qt-project.org/

This is a self containing framework which contains developers tools, GUI builders, String/IO/XML/Thread classes, Audio/Video controls, HTML widgets and many, many more features. It's built to be completely multi-platform, one code for all systems.

这是一个包含自包含框架的框架,其中包含开发人员工具,GUI构建器,String / IO / XML / Thread类,音频/视频控件,HTML小部件以及许多其他功能。它构建为完全多平台,一个代码适用于所有系统。

In contrary to wxWidgets, it feels more object-oriented, and has by far better documentation and its better maintained.

与wxWidgets相反,它感觉更加面向对象,并且具有更好的文档和更好的维护。

See it online: http://qt-project.org/doc/qt-4.8/

在线查看:http://qt-project.org/doc/qt-4.8/

EDIT- 6 years since the original Answer. I should point to Qt5 - http://www.qt.io/

编辑 - 自原答案起6年。我应该指向Qt5 - http://www.qt.io/

#2


I would recommend wxWidgets. It's crossplatform and works with Visual C++.

我会推荐wxWidgets。它是跨平台的,适用于Visual C ++。

There's also Qt (see Colins post) which is what KDE (Linux desktop manager) uses. It has a more restrictive license though.

还有Qt(参见Colins帖子),这是KDE(Linux桌面管理器)使用的。但它有更严格的许可证。

#3


You can also have a look at FLTK

你也可以看看FLTK

FLTK (pronounced "fulltick") is a cross-platform C++ GUI toolkit for UNIX®/Linux® (X11), Microsoft® Windows®, and MacOS® X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL® and its built-in GLUT emulation.

FLTK(发音为“fulltick”)是用于UNIX®/Linux®(X11),Microsoft®Windows®和MacOS®X的跨平台C ++ GUI工具包.FLTK提供现代GUI功能,没有膨胀,并通过OpenGL®支持3D图形及其内置的GLUT仿真。

FLTK is designed to be small and modular enough to be statically linked, but works fine as a shared library. FLTK also includes an excellent UI builder called FLUID that can be used to create applications in minutes.

FLTK设计为小型和模块化,足以静态链接,但作为共享库可以正常工作。 FLTK还包括一个名为FLUID的优秀UI构建器,可用于在几分钟内创建应用程序。

Here are some quickstart screencasts

以下是一些快速入门的截屏视频

#4


  1. GTK+
  2. QT
  3. wxWidgets

If you're asking about .NET then (assuming that's what Visual C++ 2008 is) then both Linux and Mac OS X users can run .NET applications with Mono.

如果你问的是.NET(假设这就是Visual C ++ 2008),那么Linux和Mac OS X用户都可以使用Mono运行.NET应用程序。

#5


Since the user interface is so simple, I would advise you to start in Windows with Visual Studio, and keep all the user interface stuff in separate files, decoupling it completely from the rest of your application.

由于用户界面非常简单,我建议您使用Visual Studio在Windows中启动,并将所有用户界面内容保存在单独的文件中,将其与应用程序的其余部分完全分离。

Then, on OS X, you'll get the best visual results by creating a Cocoa application and writing the user interface in Objective C in combination with Interface Builder. You can then easily hook up the interface with your internal C++ code. (The Objective C compiler understands C++ code in the same file as the Objective C code.)

然后,在OS X上,您将通过创建Cocoa应用程序并在Objective C中结合Interface Builder编写用户界面来获得最佳视觉效果。然后,您可以轻松地将接口与内部C ++代码连接起来。 (Objective C编译器在与Objective C代码相同的文件中理解C ++代码。)

This will let you produce a cross-platform application that looks just right on both Windows and OS X, something that QT or other cross-platform kits will likely never completely achieve.

这将使您能够生成一个跨平台的应用程序,该应用程序在Windows和OS X上都是正确的,这是QT或其他跨平台工具包可能永远无法完全实现的。

#6


I'd suggest you look at the Qt toolkit. It contains cross-platform UI elements. It is possible to use this with VS2008.

我建议你看一下Qt工具包。它包含跨平台的UI元素。可以在VS2008上使用它。

#7


Gtkmm is C++ and is proved to work in linux and windows with Visual Studio.

Gtkmm是C ++,并且已经证明可以在Linux和Windows中使用Visual Studio。

#1


Use Qt4. http://qt-project.org/

使用Qt4。 http://qt-project.org/

This is a self containing framework which contains developers tools, GUI builders, String/IO/XML/Thread classes, Audio/Video controls, HTML widgets and many, many more features. It's built to be completely multi-platform, one code for all systems.

这是一个包含自包含框架的框架,其中包含开发人员工具,GUI构建器,String / IO / XML / Thread类,音频/视频控件,HTML小部件以及许多其他功能。它构建为完全多平台,一个代码适用于所有系统。

In contrary to wxWidgets, it feels more object-oriented, and has by far better documentation and its better maintained.

与wxWidgets相反,它感觉更加面向对象,并且具有更好的文档和更好的维护。

See it online: http://qt-project.org/doc/qt-4.8/

在线查看:http://qt-project.org/doc/qt-4.8/

EDIT- 6 years since the original Answer. I should point to Qt5 - http://www.qt.io/

编辑 - 自原答案起6年。我应该指向Qt5 - http://www.qt.io/

#2


I would recommend wxWidgets. It's crossplatform and works with Visual C++.

我会推荐wxWidgets。它是跨平台的,适用于Visual C ++。

There's also Qt (see Colins post) which is what KDE (Linux desktop manager) uses. It has a more restrictive license though.

还有Qt(参见Colins帖子),这是KDE(Linux桌面管理器)使用的。但它有更严格的许可证。

#3


You can also have a look at FLTK

你也可以看看FLTK

FLTK (pronounced "fulltick") is a cross-platform C++ GUI toolkit for UNIX®/Linux® (X11), Microsoft® Windows®, and MacOS® X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL® and its built-in GLUT emulation.

FLTK(发音为“fulltick”)是用于UNIX®/Linux®(X11),Microsoft®Windows®和MacOS®X的跨平台C ++ GUI工具包.FLTK提供现代GUI功能,没有膨胀,并通过OpenGL®支持3D图形及其内置的GLUT仿真。

FLTK is designed to be small and modular enough to be statically linked, but works fine as a shared library. FLTK also includes an excellent UI builder called FLUID that can be used to create applications in minutes.

FLTK设计为小型和模块化,足以静态链接,但作为共享库可以正常工作。 FLTK还包括一个名为FLUID的优秀UI构建器,可用于在几分钟内创建应用程序。

Here are some quickstart screencasts

以下是一些快速入门的截屏视频

#4


  1. GTK+
  2. QT
  3. wxWidgets

If you're asking about .NET then (assuming that's what Visual C++ 2008 is) then both Linux and Mac OS X users can run .NET applications with Mono.

如果你问的是.NET(假设这就是Visual C ++ 2008),那么Linux和Mac OS X用户都可以使用Mono运行.NET应用程序。

#5


Since the user interface is so simple, I would advise you to start in Windows with Visual Studio, and keep all the user interface stuff in separate files, decoupling it completely from the rest of your application.

由于用户界面非常简单,我建议您使用Visual Studio在Windows中启动,并将所有用户界面内容保存在单独的文件中,将其与应用程序的其余部分完全分离。

Then, on OS X, you'll get the best visual results by creating a Cocoa application and writing the user interface in Objective C in combination with Interface Builder. You can then easily hook up the interface with your internal C++ code. (The Objective C compiler understands C++ code in the same file as the Objective C code.)

然后,在OS X上,您将通过创建Cocoa应用程序并在Objective C中结合Interface Builder编写用户界面来获得最佳视觉效果。然后,您可以轻松地将接口与内部C ++代码连接起来。 (Objective C编译器在与Objective C代码相同的文件中理解C ++代码。)

This will let you produce a cross-platform application that looks just right on both Windows and OS X, something that QT or other cross-platform kits will likely never completely achieve.

这将使您能够生成一个跨平台的应用程序,该应用程序在Windows和OS X上都是正确的,这是QT或其他跨平台工具包可能永远无法完全实现的。

#6


I'd suggest you look at the Qt toolkit. It contains cross-platform UI elements. It is possible to use this with VS2008.

我建议你看一下Qt工具包。它包含跨平台的UI元素。可以在VS2008上使用它。

#7


Gtkmm is C++ and is proved to work in linux and windows with Visual Studio.

Gtkmm是C ++,并且已经证明可以在Linux和Windows中使用Visual Studio。