简体   繁体   English

图形仅使用标准C ++?

[英]Graphics using Standard C++ only?

I just want to know whether Standard C++ allows GUI programming? 我只是想知道标准C ++是否允许GUI编程?

There are 2 aspects of this: 这有两个方面:

  1. Widgets for UI like window, dialog, push button, etc 用于UI的小部件,如窗口,对话框,按钮等
  2. Graphics like drawing circle, rectangle, spline, etc 图形像绘制圆形,矩形,样条曲线等

I have been using Qt for my UI & haven't seen anybody doing GUI in C++ only. 我一直在使用Qt作为我的UI,并且没有看到任何人只在C ++中使用GUI。

PS: I am concerned with C++ language only, I know that Java allows GUI programming! PS:我只关心C ++语言,我知道Java允许GUI编程!

UPDATE: A new question was added here: How frameworks like Qt create GUI, if C++ has no functionality for that? 更新:这里添加了一个新问题: 如果C ++没有功能,那么像Qt这样的框架如何创建GUI?

No, this isn't possible. 不,这是不可能的。 C++ works on many devices, some of which simply don't have that capability. C ++适用于许多设备,其中一些设备根本没有这种功能。

Qt can do this, usually because the Operating Systems on which it runs do offer that functionality. Qt可以做到这一点,通常是因为它运行的操作系统确实提供了这种功能。 It's usually exposed as a set of C functions, which in practice means they're callable by the C++ code in Qt. 它通常作为一组C函数公开,实际上它们可以通过Qt中的C ++代码调用。 What the OS uses internally, who knows. 操作系统内部使用什么,谁知道。 It may even leave some of the work to the GPU nowadays. 它现在甚至可能将一些工作留给GPU。

And on some embedded systems, Qt just gets a pointer to the screen memory, and does all the pixel manipulations itself. 在某些嵌入式系统中,Qt只是获取指向屏幕内存的指针,并自行完成所有像素操作。 That's not a solution when you have to share the screen with multiple applications, but for single-function devices it definitely works. 当你必须与多个应用程序共享屏幕时,这不是一个解决方案,但对于单功能设备,它绝对有效。

No. There is nothing about GUI in C++ standard. 没有.C ++标准中没有GUI。

Frameworks use OS facilities. 框架使用OS工具。 Standard C++ - no. 标准C ++ - 没有。

No, it's not included. 不,它不包括在内。 You may want to read the explanation from the language creator: http://www.stroustrup.com/bs_faq.html#gui 您可能需要阅读语言创建者的解释: http//www.stroustrup.com/bs_faq.html#gui

GUI frameworks use the low-level facilities provided by the operating system API or the window manager API. GUI框架使用操作系统API或窗口管理器API提供的低级设施。

It allows it, in the sense that it doesn't restrict the ability of an implementation to make available GUI facilities should it choose. 它允许它,因为它不会限制实现在选择时提供可用GUI设施的能力。

The standard doesn't required a GUI environment to be available - lots of implementations' run time environments don't have one available so there is no mandated standard interface. 该标准不需要GUI环境可用 - 许多实现的运行时环境没有可用的环境,因此没有强制标准接口。

There is also no standardized optional GUI interface, either. 也没有标准化的可选GUI界面。

Standard C++ does not prohibit GUI programming (IOW, it allows it), but at the same time it does not provide any standard library functionality for that. 标准C ++不禁止GUI编程(IOW,它允许),但同时它不提供任何标准库功能。 That's beyond the scope of the language and its standard library and is OS/platform-specific. 这超出了语言及其标准库的范围,并且是特定于OS /平台的。

About the only thing graphics you can do in plain C++ directly is ASCII art . 关于你在普通C ++中可以直接做的图形是ASCII艺术 :) :)

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

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