{"id":968741,"date":"2024-12-27T05:09:47","date_gmt":"2024-12-26T21:09:47","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/968741.html"},"modified":"2024-12-27T05:09:49","modified_gmt":"2024-12-26T21:09:49","slug":"qt%e4%b8%ad%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/968741.html","title":{"rendered":"qt\u4e2d\u5982\u4f55\u4f7f\u7528python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183348\/2d797e67-5399-43a7-b26a-e8a90a8a1a70.webp\" alt=\"qt\u4e2d\u5982\u4f55\u4f7f\u7528python\" \/><\/p>\n<p><p> \u5728Qt\u4e2d\u4f7f\u7528Python\u6709\u591a\u79cd\u65b9\u6cd5\uff0c<strong>\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528PyQt\u3001PySide\u3001\u901a\u8fc7Qt for Python\u3001\u96c6\u6210Python\u811a\u672c\u7b49<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4f7f\u7528PyQt\u548cPySide\u662f\u6700\u4e3a\u666e\u904d\u7684\u65b9\u6cd5<\/strong>\uff0c\u56e0\u4e3a\u5b83\u4eec\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684Qt\u5e93\u7684Python\u7ed1\u5b9a\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u5229\u7528Qt\u7684\u5f3a\u5927\u529f\u80fd\u6765\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7PyQt\u548cPySide\u5728Qt\u4e2d\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001PyQt\u4e0ePython\u7684\u7ed3\u5408<\/h3>\n<\/p>\n<p><p>PyQt\u662f\u7531Riverbank Computing\u5f00\u53d1\u7684Python\u7ed1\u5b9a\uff0c\u7528\u4e8eQt\u5e94\u7528\u6846\u67b6\u3002\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7ec4\u4ef6\u548c\u5de5\u5177\u6765\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5PyQt<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5PyQt\u3002\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install PyQt5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728Python\u9879\u76ee\u4e2d\u5bfc\u5165PyQt\u5e93\uff0c\u5e76\u5f00\u59cb\u5f00\u53d1Qt\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684PyQt\u5e94\u7528<\/h4>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684PyQt\u5e94\u7528\u7a0b\u5e8f\u793a\u4f8b\uff0c\u5b83\u521b\u5efa\u4e86\u4e00\u4e2a\u7a97\u53e3\u5e76\u663e\u793a\u201cHello, World!\u201d\u7684\u6807\u7b7e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from PyQt5.QtWidgets import QApplication, QLabel, QM<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nWindow<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;My First PyQt App&quot;)<\/p>\n<p>        label = QLabel(&quot;Hello, World!&quot;)<\/p>\n<p>        self.setCentralWidget(label)<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>window = MainWindow()<\/p>\n<p>window.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684Qt\u5e94\u7528\u7a0b\u5e8f\u7a97\u53e3\uff0c\u5e76\u5728\u5176\u4e2d\u663e\u793a\u6807\u7b7e\u3002<\/p>\n<\/p>\n<p><h4>3. \u4fe1\u53f7\u4e0e\u69fd\u673a\u5236<\/h4>\n<\/p>\n<p><p>Qt\u7684\u4fe1\u53f7\u4e0e\u69fd\u673a\u5236\u662f\u5176\u6838\u5fc3\u7279\u6027\u4e4b\u4e00\uff0c\u5b83\u5141\u8bb8\u5bf9\u8c61\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\u3002\u901a\u8fc7\u4fe1\u53f7\u4e0e\u69fd\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5904\u7406\u7528\u6237\u4ea4\u4e92\uff0c\u4f8b\u5982\u6309\u94ae\u70b9\u51fb\u7b49\u4e8b\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PyQt5.QtWidgets import QPushButton<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;PyQt App with Button&quot;)<\/p>\n<p>        button = QPushButton(&quot;Click Me&quot;)<\/p>\n<p>        button.clicked.connect(self.on_button_clicked)<\/p>\n<p>        self.setCentralWidget(button)<\/p>\n<p>    def on_button_clicked(self):<\/p>\n<p>        print(&quot;Button clicked!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u6dfb\u52a0\u4e86\u4e00\u4e2a\u6309\u94ae\uff0c\u5e76\u8fde\u63a5\u4e86\u5176\u70b9\u51fb\u4e8b\u4ef6\u5230\u4e00\u4e2a\u69fd\u65b9\u6cd5<code>on_button_clicked<\/code>\uff0c\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c\u4f1a\u8f93\u51fa\u201cButton clicked!\u201d\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528PySide\u4e0ePython\u7684\u7ed3\u5408<\/h3>\n<\/p>\n<p><p>PySide\u662f\u7531Qt\u516c\u53f8\u63d0\u4f9b\u7684\u5b98\u65b9Python\u7ed1\u5b9a\uff0c\u4e0ePyQt\u7c7b\u4f3c\uff0c\u4f46\u5b83\u7684\u8bb8\u53ef\u8bc1\u4e0ePyQt\u4e0d\u540c\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5PySide<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5PySide\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install PySide2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install PySide6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684PySide\u5e94\u7528<\/h4>\n<\/p>\n<p><p>PySide\u7684\u7528\u6cd5\u4e0ePyQt\u975e\u5e38\u76f8\u4f3c\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from PySide2.QtWidgets import QApplication, QLabel, QMainWindow<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;My First PySide App&quot;)<\/p>\n<p>        label = QLabel(&quot;Hello, World!&quot;)<\/p>\n<p>        self.setCentralWidget(label)<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>window = MainWindow()<\/p>\n<p>window.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u4fe1\u53f7\u4e0e\u69fd\u673a\u5236<\/h4>\n<\/p>\n<p><p>PySide\u540c\u6837\u652f\u6301\u4fe1\u53f7\u4e0e\u69fd\u673a\u5236\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PySide2.QtWidgets import QPushButton<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;PySide App with Button&quot;)<\/p>\n<p>        button = QPushButton(&quot;Click Me&quot;)<\/p>\n<p>        button.clicked.connect(self.on_button_clicked)<\/p>\n<p>        self.setCentralWidget(button)<\/p>\n<p>    def on_button_clicked(self):<\/p>\n<p>        print(&quot;Button clicked!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001Qt Designer\u4e0ePython\u7684\u96c6\u6210<\/h3>\n<\/p>\n<p><p>Qt Designer\u662f\u4e00\u4e2a\u56fe\u5f62\u5316\u8bbe\u8ba1\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u8bbe\u8ba1Qt\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u3002\u8bbe\u8ba1\u597d\u7684UI\u6587\u4ef6\u53ef\u4ee5\u901a\u8fc7<code>pyuic<\/code>\u5de5\u5177\u8f6c\u6362\u4e3aPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efaUI\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Qt Designer\u521b\u5efaUI\u6587\u4ef6\uff0c\u5e76\u4fdd\u5b58\u4e3a<code>mainwindow.ui<\/code>\u3002<\/p>\n<\/p>\n<p><h4>2. \u8f6c\u6362UI\u6587\u4ef6\u4e3aPython\u4ee3\u7801<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06UI\u6587\u4ef6\u8f6c\u6362\u4e3aPython\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyuic5 mainwindow.ui -o mainwindow.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5728Python\u9879\u76ee\u4e2d\u4f7f\u7528<\/h4>\n<\/p>\n<p><p>\u8f6c\u6362\u540e\u7684<code>mainwindow.py<\/code>\u53ef\u4ee5\u76f4\u63a5\u5728Python\u9879\u76ee\u4e2d\u4f7f\u7528\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from PyQt5.QtWidgets import QApplication, QMainWindow<\/p>\n<p>from mainwindow import Ui_MainWindow<\/p>\n<p>class MainWindow(QMainWindow, Ui_MainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setupUi(self)<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>window = MainWindow()<\/p>\n<p>window.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u96c6\u6210Python\u811a\u672c\u4e0eQt\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5728Qt\u5e94\u7528\u4e2d\u6267\u884cPython\u811a\u672c\u3002\u53ef\u4ee5\u901a\u8fc7Python\u6807\u51c6\u5e93\u63d0\u4f9b\u7684<code>subprocess<\/code>\u6a21\u5757\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528subprocess\u6a21\u5757<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5728Qt\u5e94\u7528\u4e2d\u6267\u884cPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>import subprocess<\/p>\n<p>from PyQt5.QtWidgets import QApplication, QPushButton, QMainWindow<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;Run Python Script&quot;)<\/p>\n<p>        button = QPushButton(&quot;Run Script&quot;)<\/p>\n<p>        button.clicked.connect(self.run_script)<\/p>\n<p>        self.setCentralWidget(button)<\/p>\n<p>    def run_script(self):<\/p>\n<p>        subprocess.run([&quot;python&quot;, &quot;script.py&quot;])<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>window = MainWindow()<\/p>\n<p>window.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u5f53\u6309\u94ae\u88ab\u70b9\u51fb\u65f6\uff0c<code>script.py<\/code>\u811a\u672c\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001Qt for Python\u7684\u4f7f\u7528<\/h3>\n<\/p>\n<p><p>Qt for Python\u662fQt\u516c\u53f8\u63d0\u4f9b\u7684\u53e6\u4e00\u79cdPython\u7ed1\u5b9a\uff0c\u4f7f\u7528PySide6\u5e93\u3002\u5176\u4f7f\u7528\u65b9\u5f0f\u4e0ePyQt\u548cPySide\u57fa\u672c\u76f8\u540c\u3002<\/p>\n<\/p>\n<p><h4>1. \u5b89\u88c5Qt for Python<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install PySide6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Qt for Python\u5e94\u7528<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from PySide6.QtWidgets import QApplication, QLabel, QMainWindow<\/p>\n<p>class MainWindow(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.setWindowTitle(&quot;My First Qt for Python App&quot;)<\/p>\n<p>        label = QLabel(&quot;Hello, World!&quot;)<\/p>\n<p>        self.setCentralWidget(label)<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>window = MainWindow()<\/p>\n<p>window.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u4f7f\u7528QML\u4e0ePython\u7684\u7ed3\u5408<\/h3>\n<\/p>\n<p><p>Qt\u63d0\u4f9b\u4e86QML\u8bed\u8a00\u7528\u4e8e\u8bbe\u8ba1\u7528\u6237\u754c\u9762\uff0cPython\u53ef\u4ee5\u4e0eQML\u7ed3\u5408\u4f7f\u7528\u4ee5\u6784\u5efa\u73b0\u4ee3\u7528\u6237\u754c\u9762\u3002<\/p>\n<\/p>\n<p><h4>1. \u521b\u5efaQML\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684<code>main.qml<\/code>\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-qml\">import QtQuick 2.0<\/p>\n<p>Rectangle {<\/p>\n<p>    width: 200<\/p>\n<p>    height: 200<\/p>\n<p>    Text {<\/p>\n<p>        text: &quot;Hello, QML!&quot;<\/p>\n<p>        anchors.centerIn: parent<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528Python\u52a0\u8f7dQML<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>from PySide6.QtWidgets import QApplication<\/p>\n<p>from PySide6.QtQuick import QQuickView<\/p>\n<p>from PySide6.QtCore import QUrl<\/p>\n<p>app = QApplication(sys.argv)<\/p>\n<p>view = QQuickView()<\/p>\n<p>view.setSource(QUrl.fromLocalFile(&#39;main.qml&#39;))<\/p>\n<p>view.show()<\/p>\n<p>app.exec_()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5728Qt\u4e2d\u5145\u5206\u5229\u7528Python\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u521b\u5efa\u51fa\u529f\u80fd\u4e30\u5bcc\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u65e0\u8bba\u662f\u4f7f\u7528PyQt\u3001PySide\u8fd8\u662fQt for Python\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u52bf\u548c\u9002\u7528\u573a\u666f\uff0c\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Qt\u4e2d\u4f7f\u7528Python\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u4f7f\u7528Python\u7ed3\u5408Qt\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u6709\u591a\u4e2a\u4f18\u70b9\u3002\u9996\u5148\uff0cPython\u662f\u4e00\u79cd\u6613\u4e8e\u5b66\u4e60\u548c\u4f7f\u7528\u7684\u8bed\u8a00\uff0c\u9002\u5408\u5feb\u901f\u5f00\u53d1\u548c\u539f\u578b\u8bbe\u8ba1\u3002\u5176\u6b21\uff0cQt\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u5f62\u7528\u6237\u754c\u9762\u529f\u80fd\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u7f8e\u89c2\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u5e94\u7528\u3002\u6b64\u5916\uff0cPython\u7684\u5e93\u548c\u6846\u67b6\u751f\u6001\u7cfb\u7edf\u4e5f\u975e\u5e38\u5e9e\u5927\uff0c\u53ef\u4ee5\u4e0eQt\u65e0\u7f1d\u96c6\u6210\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Qt\u4e2d\u8bbe\u7f6ePython\u5f00\u53d1\u73af\u5883\uff1f<\/strong><br \/>\u8981\u5728Qt\u4e2d\u8bbe\u7f6ePython\u5f00\u53d1\u73af\u5883\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u548cPyQt\u6216PySide\u5e93\uff0c\u8fd9\u4e24\u8005\u90fd\u662fPython\u4e0eQt\u7684\u7ed1\u5b9a\u5e93\u3002\u63a5\u4e0b\u6765\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5PyQt\u6216PySide\uff0c\u4f8b\u5982\uff1a<code>pip install PyQt5<\/code> \u6216 <code>pip install PySide2<\/code>\u3002\u5b8c\u6210\u5b89\u88c5\u540e\uff0c\u53ef\u4ee5\u5728\u4f60\u7684IDE\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u9879\u76ee\uff0c\u5e76\u5f00\u59cb\u5bfc\u5165Qt\u6a21\u5757\u8fdb\u884c\u5f00\u53d1\u3002\u914d\u7f6e\u5408\u9002\u7684IDE\uff08\u5982PyCharm\uff09\u53ef\u4ee5\u63d0\u4f9b\u66f4\u597d\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5c06\u73b0\u6709\u7684C++ Qt\u9879\u76ee\u8f6c\u6362\u4e3aPython\uff1f<\/strong><br \/>\u5c06\u73b0\u6709\u7684C++ Qt\u9879\u76ee\u8f6c\u6362\u4e3aPython\u5e76\u4e0d\u662f\u4e00\u9879\u7b80\u5355\u7684\u4efb\u52a1\uff0c\u4f46\u53ef\u4ee5\u9010\u6b65\u8fdb\u884c\u3002\u53ef\u4ee5\u9009\u62e9\u4ece\u9879\u76ee\u4e2d\u63d0\u53d6\u6838\u5fc3\u903b\u8f91\uff0c\u5e76\u7528Python\u91cd\u5199\u8fd9\u4e9b\u90e8\u5206\u3002\u540c\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982<code>pyuic<\/code>\u5c06Qt Designer\u751f\u6210\u7684.ui\u6587\u4ef6\u8f6c\u6362\u4e3aPython\u4ee3\u7801\u3002\u6b64\u5916\uff0c\u9010\u6b65\u91cd\u6784\u548c\u91cd\u5199\u9879\u76ee\u529f\u80fd\uff0c\u9010\u6e10\u66ff\u6362C++\u4ee3\u7801\u4e5f\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u505a\u6cd5\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5b9e\u73b0Qt\u7684\u4fe1\u53f7\u4e0e\u69fd\u673a\u5236\uff1f<\/strong><br \/>\u5728Python\u4e2d\u5b9e\u73b0Qt\u7684\u4fe1\u53f7\u4e0e\u69fd\u673a\u5236\u4e0eC++\u76f8\u4f3c\u3002\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u4fe1\u53f7\u5e76\u4f7f\u7528<code>pyqtSignal<\/code>\u6216<code>Signal<\/code>\uff08\u53d6\u51b3\u4e8e\u4f7f\u7528\u7684\u5e93\uff09\u8fdb\u884c\u5b9a\u4e49\u3002\u63a5\u7740\uff0c\u4f7f\u7528<code>connect()<\/code>\u65b9\u6cd5\u5c06\u4fe1\u53f7\u4e0e\u5bf9\u5e94\u7684\u69fd\uff08\u5904\u7406\u51fd\u6570\uff09\u8fde\u63a5\u8d77\u6765\u3002\u5f53\u4fe1\u53f7\u88ab\u89e6\u53d1\u65f6\uff0c\u69fd\u51fd\u6570\u4f1a\u81ea\u52a8\u88ab\u8c03\u7528\u3002\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u4e8b\u4ef6\u548c\u4ea4\u4e92\uff0c\u4f7f\u5f97\u7a0b\u5e8f\u7684\u7ed3\u6784\u66f4\u52a0\u6e05\u6670\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Qt\u4e2d\u4f7f\u7528Python\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528PyQt\u3001PySide\u3001\u901a\u8fc7Qt for Python\u3001 [&hellip;]","protected":false},"author":3,"featured_media":968749,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/968741"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=968741"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/968741\/revisions"}],"predecessor-version":[{"id":968752,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/968741\/revisions\/968752"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/968749"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=968741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=968741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=968741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}