如何通过pythoncapi实现QT与Python的接口

2024-09-28 23:30:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个与python接口的Qt程序。我必须将Cype类的C++对象直接发送到Python

    1) Need to create a Python Module ( let say Shape )
    2) Need to add a Python Class PCircle in Shape module which is equivalent to C++ 
       Circle class.
    3) Do the calculation on Python Environment ( Python 3.4)
    4) Populate the data into PCircle Object in Python
    5) Send it back to Qt Environment by storing the PCircle values to C++ Circle Object    
    and show the changes in real time in display

这就是我将如何描述我的问题,我的目标是做什么,如果有什么不清楚,请评论。你知道吗

谢谢


Tags: theto对象in程序objectenvironmentcreate
1条回答
网友
1楼 · 发布于 2024-09-28 23:30:56
  1. 模块只是一个python文件。。。所以只要创建一个名为形状.py你知道吗
  2. 打开形状.py并添加

代码

from PyQt4 import QWidget
class PCircle(QWidget):
    #implement methods here that are available to the QTCircleWidget
  1. 在python land做一些计算

代码

def calculation(something):
    return somthing**2
  1. 只需添加代码my_circle = PCircle(x,y,radius)
  2. 打印出你想要返回给调用程序的任何数据。调用程序将需要解析该数据并对其进行处理。。。。你知道吗

相关问题 更多 >