“环境变量 PYSIDE_DESIGNER_PLUGINS 未设置,正在退出。”

use*_*443 9 qt qt-creator pyside6

我已经安装了开源 qt Creator(免费版本)并创建了非常简单的桌面应用程序。我能够创建简单的窗口,但是当我运行时,出现以下错误:

我尝试关注此页面,但无法理解如何解决此问题

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.
Run Code Online (Sandbox Code Playgroud)

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_())
Run Code Online (Sandbox Code Playgroud)

添加 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>
Run Code Online (Sandbox Code Playgroud)

Mic*_*ael 8

您正在看到来自 PySide6 中名为“自定义小部件”的新实验功能的信息丰富的消息。要使消息静音,您可以将变量“PYSIDE_DESIGNER_PLUGINS”设置为“。” 对于当前文件夹。

https://www.qt.io/blog/qt-for-python-6.1指出:

发布了适用于 Linux 和 Windows 的新实验性插件,支持使用 Python 编写自定义小部件,然后可以从 Qt Designer 中选择这些小部件以在布局中使用。> 在 macOS 上启用此功能需要一些额外的魔法。我们希望能在 6.1.1 中做好准备!

有关此功能的更多信息可以在这里找到:

https://doc-snapshots.qt.io/qtforpython-dev/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer

  • 将环境变量设置为“.” 不会为我静音该消息,它将其更改为: `qt.pysideplugin: 在 '.' 中找不到 python 文件。` 至少现在很清楚,这意味着什么,但还有一种方法可以完全使其静音? (12认同)