简体   繁体   English

为什么在Visual Studio中用c ++编写GUI应用程序的代码与控制台应用程序不同?

[英]Why the code to write GUI application in c++ in Visual Studio is different than to console application?

I am just a begginer in c++ and I am trying to learn it for my assignment. 我只是C ++的入门者,我正在尝试为我的作业学习它。 I've been learning how to write simple console applications for past few weeks and everything was going fine, until I tried use that knowledge to write GUI application using the visual editor. 在过去的几周中,我一直在学习如何编写简单的控制台应用程序,并且一切都进行得很好,直到我尝试使用该知识通过可视化编辑器编写GUI应用程序。 I created a gui, and when I double pressed the button, the code was similar to C++ but not exactly the same. 我创建了一个gui,当我双击按钮时,代码类似于C ++,但不完全相同。

My question is, is there any way to still use the visual editor and use the standard c++ or do I have to learn the other (visual?) c++ to make the GUI usable? 我的问题是,有没有办法仍然使用可视化编辑器并使用标准c ++,还是必须学习其他(可视化)c ++才能使GUI可用?

Well, you can use standard C++ (or C for that matter) to write a GUI, but you will have to use the Windows API to draw your GUIs and handle the messages that your application will receive from the operating system. 好了,您可以使用标准的C ++(或C)编写GUI,但是必须使用Windows API绘制GUI并处理应用程序将从操作系统接收到的消息。

But, Visual C++ is actually helping you here in giving you a template starting point application to which you can add your specific functionality. 但是,Visual C ++实际上在这里帮助您提供模板起点应用程序,您可以在其中添加特定的功能。 What it generates for you is C++, although it will be heavily littered with macros &c. 它为您生成的 C ++,尽管它会被宏&c乱七八糟。 which does make it appear quite alien on first inspection. 的确使它在第一次检查时显得很陌生。

That all said, I believe the cool cats use Qt these days. 综上所述,我相信这些天猫们会使用Qt。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM