我已经安装了开源的qt创建者(免费版本),并创建了非常简单的桌面应用程序。我能够创建简单的窗口,但是当我运行时,我会收到以下错误:
我试着遵循这一页,但无法理解如何解决这个问题。
https://www.qt.io/blog/qt-for-python-6.1
Environment variable PYSIDE_DESIGNER_PLUGINS is not set, bailing out.
No instance of QPyDesignerCustomWidgetCollection was found.
Python文件
# This Python file uses the following encoding: utf-8
import os
from pathlib import Path
import sys
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtCore import QFile
from PySide6.QtUiTools import QUiLoader
class test(QMainWindow):
def __init__(self):
super(test, self).__init__()
self.load_ui()
def load_ui(self):
loader = QUiLoader()
path = os.fspath(Path(__file__).resolve().parent / "form.ui")
ui_file = QFile(path)
ui_file.open(QFile.ReadOnly)
loader.load(ui_file, self)
ui_file.close()
if __name__ == "__main__":
app = QApplication([])
widget = test()
widget.show()
sys.exit(app.exec_())
添加xml
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>test3</class>
<widget class="QMainWindow" name="test3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1332</width>
<height>702</height>
</rect>
</property>
<property name="windowTitle">
<string>test3</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>300</x>
<y>240</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1332</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen"/>
<addaction name="actionsave"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Edit</string>
</property>
</widget>
<widget class="QMenu" name="menuArchive_and_update_indicator">
<property name="title">
<string>Archive and update indicator</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuArchive_and_update_indicator"/>
</widget>
<action name="actionOpen">
<property name="text">
<string>Open</string>
</property>
</action>
<action name="actionsave">
<property name="text">
<string>Save</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
发布于 2021-07-31 19:55:16
您正在从PySide6中的一个名为“自定义小部件”的新的实验性特性中看到一条信息。要使消息保持沉默,可以将变量"PYSIDE_DESIGNER_PLUGINS“设置为”“。用于当前文件夹。
https://www.qt.io/blog/qt-for-python-6.1声明:
为Linux和Windows提供了一个新的实验性插件,它提供>支持用Python编写自定义小部件,然后可以从Qt设计器中选择>用于布局。需要一些额外的魔法才能在macOS上启用此功能。我们希望在6.1.1中做好准备!
有关此功能的更多信息可以在这里找到:
发布于 2022-07-14 02:26:45
有一种方法可以使
Environment variable PYSIDE_DESIGNER_PLUGINS is not set, bailing out.
“消息消失”是将PYSIDE_DESIGNER_PLUGINS
(例如,os.environ["PYSIDE_DESIGNER_PLUGINS"]="."
)设置为具有空白register*.py
文件的文件夹,例如,将空白文件命名为register_dummy.py
。
你还会有
No instance of QPyDesignerCustomWidgetCollection was found.
不过,因为register_dummy.py
文件不调用QPyDesignerCustomWidgetCollection.registerCustomWidget
函数。为了摆脱这个问题,您只需制作一个自定义小部件,也许可以使用在可接受的答案中引用的链接中提到的wigglywidget
,也可以在site-packages/PySide6/examples/widgetbinding
中找到。
https://stackoverflow.com/questions/68528717
复制相似问题