我对 Qt 有点陌生。我使用 C++ 编程已有一段时间了。
我想在 Qt/C++ 中创建一个应用程序,因为创建 GUI 非常容易。我想知道我是否可以用 native C++ 编写 C++ 类并在我的 Qt 应用程序中使用它。
我想在 Qt 中编写 GUI 并使用我的 native C++ 代码而不是 Qt/C++ 进行所有处理。是否可以在原生 C++ 中编译 DLL,然后在 QtC++ 应用程序中加载和使用它?
我真的很想用 C++ 编写一个 GUI 应用程序。
最佳答案
没有与“Qt/C++”相对的“原生 C++”之类的东西,所以这个问题毫无意义。所有核心 Qt 代码都是编译的原生 C++,就像任何使用 Qt 的 C++ 应用程序一样。
作为JBentley已正式注意到:
[You may be] confused because of the code generating tools Qt uses, like moc [or uic]. Those don't mean that C++ compiles natively while Qt doesn't. All those tools do is provide a convenient way to produce a lot of boiler code that the framework relies on, so that the programmer can pretend they don't exist and use things like Qt's slots and signals. The final code which you compile and link is ordinary C++, with calls into the Qt library (also C++) which you've used.
如果您要问的是“我是否被迫在我的应用程序的所有部分中使用 Qt 类”,那么不会 - 没有人强制您这样做。如果您的应用程序的某些部分已经使用 boost 或标准 C++ 库类编写,那很好。
你要明白Qt是模块化设计的,提供了很多非GUI的功能。您可以在代码的非 gui 部分使用非 gui 模块。这是一个相当干净的通用应用程序开发框架。例如,将它用于各种 Internet 服务器应用程序非常合适。
以下 Qt 模块对于非图形用户界面开发是值得注意的:
关于c++ - Qt中如何添加自定义类处理功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21172146/