Qt 有 C 接口吗? [英] Does Qt have a C interface?
问题描述
我在网上找到了相互矛盾的答案 - 有人说是,有人说不是.我也无法在官方 Qt 文档中找到任何详细信息.那么 Qt 是否有 C 绑定?
I've found conflicting answers on the web - some say it does, some say it doesn't. I was unable to find any details in the official Qt documentation either. So does Qt have C bindings or not?
推荐答案
简短回答:否.
如果你需要一个全面的 C 语言 GUI 工具包,你可以使用 GTK+.
If you need a comprehensive GUI toolkit for C, you can use GTK+.
要使用 Qt,您必须有一个 C++ 编译器.但这并不意味着您的应用程序逻辑"不能用 C 编写,不能用 C 编译器编译并小心地链接到 C++ 部分(带有 Qt 的 GUI).此应用程序逻辑可以是通用的,可链接到其他可执行文件(纯 C、混合 C/C++ 等).这完全取决于您的需要.
To use Qt, you must have a C++ compiler. But it doesn't mean that your "application logic" can't be written in C, compiled with a C compiler and carefully linked to the C++ part (the GUI with Qt). This application logic can be generic, linkable into other executables (pure-C, mixed C/C++, etc.) It all depends on what you need.
不过,Qt 非常适合 C++,即使您仍想将部分保留在 C 中,这也是决定将 C++ 用于特定项目的一个很好的理由.
Qt is great for C++, though, and it's a good reason to decide using C++ for a particular project, even if you still want to keep parts in C.
这篇关于Qt 有 C 接口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!