为 .NET 生成 Qt 绑定
我目前正在开发一个使用 Qt C++ 的项目,并且 API 通过 SIP 暴露给 Python。为了使程序在 Windows 环境中更具吸引力,我想将 API 公开给 .NET。
我发现了 qt4dotnet,尽管这只是 Qt 绑定,但我需要一些东西来为我的 API 生成这些绑定。我听说 SWIG“可能”能够为 Qt 应用程序生成绑定,尽管我似乎找不到任何帮助。
有人知道有什么可以帮忙的吗?
I'm currently working on a project that using Qt C++ and the API is exposed to Python using SIP. In order to make the program more attractive in the Windows environments I would like to expose the API to .NET.
I have found qt4dotnet although that is just Qt bindings, I need something to generate those bindings for my API. I heard SWIG "might" be able to generate bindings for Qt apps although I can't seem to find any help on this.
Anyone know something that could help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能值得研究ActiveQt,并阅读此来自诺基亚的文档,详细介绍了 ActiveQt 与 .NET Framework 的集成。
还有一个 StackOverflow 帖子 其中讨论使用 Microsoft 的 C++/CLI 扩展包装 Qt 信号和槽(或通用方法)。
不过,我不是 .NET 开发人员,因此我可能无法提供更多帮助。
It might be worth investigating ActiveQt, and reading this document from Nokia that details integrating ActiveQt with the .NET Framework.
There's also a StackOverflow post which discusses wrapping Qt signals and slots (or generic methods) using Microsoft's C++/CLI extensions.
I'm not a .NET developer though, so I probably can't provide any more help than that.
在 kdebindings 模块中,我们有正确的 Qt 绑定 称为 Qyoto,基于我们的 SMOKE 库(我们所有绑定共享的库,用于调用 C++ API,仅依赖于 STL)。
不幸的是,由于 *nix 用户缺乏兴趣,该项目目前尚未维护。
然而,扩展基于 SMOKE 的绑定非常容易。您只需从自己的头文件、匹配的 .NET 程序集生成新的 SMOKE 库并编写 Qyoto 插件。
生成 SMOKE 库是使用 Smokegen 完成的,我编写了一个 工具,可以从 SMOKE 库生成 .NET 程序集(它但尚未合并)。
我想,需要付出一些努力才能使绑定保持最新并真正使其在 Windows 上运行,但我认为这是您的最佳选择(如果您不想手工制作绑定)。我们已经支持所有 QMetaObject 内容(包括自定义信号、槽、Q_PROPERTIES、Q_CLASSINFO 等),并且扩展绑定非常容易。
关于Windows,我曾经有一个Hello World可以工作,但现在似乎不再工作了。
如果您想参与其中,可以通过[电子邮件受保护]与我们联系或者在 Freenode 上的 #kde-bindings 上。
PS:我会发布更多链接,但垃圾邮件防护不允许我这样做。您可以在projects.kde.org/smokeqt、projects.kde.org/smokegen 和 techbase.kde.org 上找到有关 SMOKE 的更多信息。
In the kdebindings module, we have proper Qt bindings called Qyoto, based on our SMOKE library (a library shared by all our bindings, used to call C++ API, only depends on the STL).
Unfortunately the project is unmaintained as of now, due to lack of interest from *nix users.
However, it's very easy to extend SMOKE based bindings. You only need to generate a new SMOKE library from your own header files, a matching .NET assembly and write a Qyoto plugin.
Generating the SMOKE library is done with smokegen and I've written a tool that generates .NET assemblies from SMOKE libraries (it hasn't been merged yet, however).
I guess that it will require some effort to bring the bindings up to date and actually make them work on Windows, but I think it's the best choice you have (if you don't want to hand-craft bindings). We already have support for all the QMetaObject stuff (including custom Signals, Slots, Q_PROPERTIES, Q_CLASSINFO, etc.) and extending the bindings is quite easy.
Regarding Windows, I've once got a Hello World working, but it seems that it isn't working anymore.
If you want to get involved, you can contact us at [email protected] or on #kde-bindings on Freenode.
P.S.: I would post more links, but the spam protection won't let me. You can find more information about SMOKE on projects.kde.org/smokeqt, projects.kde.org/smokegen and techbase.kde.org.