到目前为止,我所有的c++程序都在使用命令行界面,我唯一使用过的语言是PHP,它不支持gui。
我从哪里开始与图形用户界面编程在c++ ?我如何创建一个?
到目前为止,我所有的c++程序都在使用命令行界面,我唯一使用过的语言是PHP,它不支持gui。
我从哪里开始与图形用户界面编程在c++ ?我如何创建一个?
当前回答
给出“以Windows XP为例”的评论,那么你的选项是:
Interact directly with the operating system via its API, which for Microsoft Windows is surprise surprise call Windows API. The definitive reference for the WinAPI is Microsoft's MSDN website. A popular online beginner tutorial for that is theForger's Win32 API Programming Tutorial. The classic book for that is Charles Petzold's Programming Windows, 5th Edition. Use a platform (both in terms of OS and compiler) specific library such as MFC, which wraps the WinAPI into C++ class. The reference for that is again MSDN. A classic book for that is Jeff Prosise's Programming Windows with MFC, 2nd Edition. If you are using say CodeGear C++ Builder, then the option here is VCL. Use a cross platform library such as GTK+ (C++ wrapper: gtkmm), Qt, wxWidgets, or FLTK that wrap the specific OS's API. The advantages with these are that in general, your program could been compiled for different OS without having to change the source codes. As have already been mentioned, they each have its own strengths and weaknesses. One consideration when selecting which one to use is its license. For the examples given, GTK+ & gtkmm is license under LGPL, Qt is under various licenses including proprietary option, wxWidgets is under its own wxWindows Licence (with a rename to wxWidgets Licence), and FLTK is under LGPL with exception. For reference, tutorial, and or books, refer to each one's website for details.
其他回答
有很多免费的可移植GUI库,每个库都有自己的优点和缺点:
Qt 亲爱的ImGui GTKmm(基于GTK+) wxWidgets FLTK 最终的+ + JUCE ...
特别是Qt有很好的教程和工具,可以帮助你入门。享受吧!
但是请注意,您应该避免使用特定于平台的功能,例如Win32 API或MFC。这毫无必要地将你捆绑在一个几乎没有任何好处的特定平台上。
用c++创建. net Windows GUI很容易。
请参阅下面来自MSDN的教程。你可以免费下载你需要的一切(Visual c++ Express)。
当然,你把自己绑在。net上,但如果你只是随便玩玩,或者只需要一个Windows应用程序,那就没问题了(大多数人仍然有Windows…到目前为止)。
给出“以Windows XP为例”的评论,那么你的选项是:
Interact directly with the operating system via its API, which for Microsoft Windows is surprise surprise call Windows API. The definitive reference for the WinAPI is Microsoft's MSDN website. A popular online beginner tutorial for that is theForger's Win32 API Programming Tutorial. The classic book for that is Charles Petzold's Programming Windows, 5th Edition. Use a platform (both in terms of OS and compiler) specific library such as MFC, which wraps the WinAPI into C++ class. The reference for that is again MSDN. A classic book for that is Jeff Prosise's Programming Windows with MFC, 2nd Edition. If you are using say CodeGear C++ Builder, then the option here is VCL. Use a cross platform library such as GTK+ (C++ wrapper: gtkmm), Qt, wxWidgets, or FLTK that wrap the specific OS's API. The advantages with these are that in general, your program could been compiled for different OS without having to change the source codes. As have already been mentioned, they each have its own strengths and weaknesses. One consideration when selecting which one to use is its license. For the examples given, GTK+ & gtkmm is license under LGPL, Qt is under various licenses including proprietary option, wxWidgets is under its own wxWindows Licence (with a rename to wxWidgets Licence), and FLTK is under LGPL with exception. For reference, tutorial, and or books, refer to each one's website for details.
我发现一个网站上有一个“简单的”教程: http://www.winprog.org/tutorial/start.html
我使用FLTK是因为Qt不是免费的。我没有选择wxWidgets,因为我的第一个测试使用了简单的Hello, World!程序产生的可执行文件为24 MB, FLTK为0.8 MB…