为大量C++创建Python绑定QT库

发布于 2025-01-24 08:19:43 字数 645 浏览 1 评论 0原文

简而言之: 您是否知道,或者有任何了解我如何实现下面提到的,python中的现有库,无论是通过绑定还是任何其他可能的解决方案?


描述:

我正在从事一个项目,我的数量很大 自定义构建快速变化 C ++ QT库(版本5.15.2)我需要在python中使用。

在过去的几周中,我对这个主题进行了很多研究。但是,我似乎找不到有关如何以适当方式执行绑定的合适解决方案。

我主要研究了shiboken,因为那是QT Framework正式支持和鼓励的Python绑定解决方案。

但是,shiboken要求我使用我想在绑定中使用的每个方法的每个方法或所需部分的每个库的 type-system 和标头文件。这对我来说是一个问题,因为我需要在c ++版本中存在的每种方法都存在于python版本中,并且手工编写该文件几乎是不可能的。

他们将需要像其他任何库一样或以类似方式从Python脚本中调用它们。

Question in short:
Do you maybe know, or have any idea how I could implement the below mentioned, existing libraries in Python, whether that be through bindings or any other possible solution?


Description:

I'm working on a project and I have a very large quantity of custom built, fast-changing C++ Qt Libraries (version 5.15.2) that I need to use in Python.

I have done a lot of research on the topic over the past few weeks. However I can't seem to find a suitable solution on how to perform the bindings in an appropriate way.

I have mainly researched Shiboken, as that is the python bindings solution that the Qt Framework officially supports and encourages.

However Shiboken requires me to handwrite a type-system and header file for each library with each method or required part of that library that I want to use in my bindings. This is an issue for me as I require every method that is present in the C++ version to be present in the Python version, and hand writing that file is practically impossible.

They will need to be called from Python scripts as any other library would, or in a similar manner.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2025-01-31 08:19:43

shiboken可能是一个不错的选择。是的,您需要在 type-system Header文件中指定每个类/struct/enum/namepace。但不是每种方法。如果您在type-system文件中指定类,则将将所有类方法提取到python。例如,此定义就足够了:

<?xml version="1.0"?>
<typesystem package="mylibrary">
    <object-type name="MyClass1"/>
    <object-type name="MyClass2"/>
</typesystem>

另外,您可以查看 pyside 来源。提取到python的库中有大量QT。很好的例子。

Shiboken could be a good choice. Yes, you need to specify each class/struct/enum/namespace in a type-system and header file. But not each method. If you specify a class in a type-system file, all the class methods will be extracted to Python. For example, this definition is enough:

<?xml version="1.0"?>
<typesystem package="mylibrary">
    <object-type name="MyClass1"/>
    <object-type name="MyClass2"/>
</typesystem>

Also, you can look at PySide sources. There is a big amount of Qt libraries extracted to Python. Good example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文