<bdo id='vVwJc'></bdo><ul id='vVwJc'></ul>
  1. <legend id='vVwJc'><style id='vVwJc'><dir id='vVwJc'><q id='vVwJc'></q></dir></style></legend>

    <i id='vVwJc'><tr id='vVwJc'><dt id='vVwJc'><q id='vVwJc'><span id='vVwJc'><b id='vVwJc'><form id='vVwJc'><ins id='vVwJc'></ins><ul id='vVwJc'></ul><sub id='vVwJc'></sub></form><legend id='vVwJc'></legend><bdo id='vVwJc'><pre id='vVwJc'><center id='vVwJc'></center></pre></bdo></b><th id='vVwJc'></th></span></q></dt></tr></i><div id='vVwJc'><tfoot id='vVwJc'></tfoot><dl id='vVwJc'><fieldset id='vVwJc'></fieldset></dl></div>

      <tfoot id='vVwJc'></tfoot>

      <small id='vVwJc'></small><noframes id='vVwJc'>

    1. 错误:QQmlApplicationEngine 无法加载组件“网络问题"

      Error: QQmlApplicationEngine failed to load component quot;Network problemquot;(错误:QQmlApplicationEngine 无法加载组件“网络问题)

        1. <tfoot id='ck3iy'></tfoot>

            <bdo id='ck3iy'></bdo><ul id='ck3iy'></ul>
              <tbody id='ck3iy'></tbody>

            <i id='ck3iy'><tr id='ck3iy'><dt id='ck3iy'><q id='ck3iy'><span id='ck3iy'><b id='ck3iy'><form id='ck3iy'><ins id='ck3iy'></ins><ul id='ck3iy'></ul><sub id='ck3iy'></sub></form><legend id='ck3iy'></legend><bdo id='ck3iy'><pre id='ck3iy'><center id='ck3iy'></center></pre></bdo></b><th id='ck3iy'></th></span></q></dt></tr></i><div id='ck3iy'><tfoot id='ck3iy'></tfoot><dl id='ck3iy'><fieldset id='ck3iy'></fieldset></dl></div>

              • <legend id='ck3iy'><style id='ck3iy'><dir id='ck3iy'><q id='ck3iy'></q></dir></style></legend>

                <small id='ck3iy'></small><noframes id='ck3iy'>

                本文介绍了错误:QQmlApplicationEngine 无法加载组件“网络问题"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我是 qml 和 python 的新手这是我得到的代码和错误:

                I'm new to qml and python This is the code and error I get:

                错误:

                QQmlApplicationEngine failed to load component
                c:%5CUsers%5Cpcmcb%5COneDrive%5CDesktop%5Capp%5Capp%5Cqml/main.qml: Network error
                

                main.py:

                mport sys
                import os
                
                from PySide6.QtGui import QGuiApplication
                from PySide6.QtQml import QQmlApplicationEngine
                
                
                if __name__ == "__main__":
                app = QGuiApplication(sys.argv)
                engine = QQmlApplicationEngine()
                engine.load(os.path.join(os.path.dirname(__file__), "qml/main.qml"))
                
                
                if not engine.rootObjects():
                    sys.exit(-1)
                sys.exit(app.exec_())
                

                main.qml:

                import QtQuick 2.15
                import QtQuick.Window 2.15
                import QtQuick.Controls 2.15
                import QtQuick.Controls.Material 2.15
                
                ApplicationWindow{
                    id: window
                    width: 400
                    height: 580
                    visible: true
                    title: qsTr("Login Page")
                }
                

                当我尝试运行代码时,它给了我上面输入的错误

                When I try to run the code it gives me the error that I typed above

                推荐答案

                load() 方法需要一个 QUrl,因此传递一个字符串可能会导致问题,更改为:

                load() method requires a QUrl so passing it a string can cause problems, change to:

                import os
                from pathlib import Path
                import sys
                
                from PySide6.QtCore import QCoreApplication, Qt, QUrl
                from PySide6.QtGui import QGuiApplication
                from PySide6.QtQml import QQmlApplicationEngine
                
                CURRENT_DIRECTORY = Path(__file__).resolve().parent
                
                
                def main():
                    app = QGuiApplication(sys.argv)
                
                    engine = QQmlApplicationEngine()
                
                    filename = os.fspath(CURRENT_DIRECTORY / "qml" / "main.qml")
                    url = QUrl.fromLocalFile(filename)
                
                    def handle_object_created(obj, obj_url):
                        if obj is None and url == obj_url:
                            QCoreApplication.exit(-1)
                
                    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)
                    engine.load(url)
                
                    sys.exit(app.exec())
                
                
                if __name__ == "__main__":
                    main()
                

                这篇关于错误:QQmlApplicationEngine 无法加载组件“网络问题"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                How to extend Python class init(如何扩展 Python 类初始化)
                What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                Initialize list with same bool value(使用相同的布尔值初始化列表)
                setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                • <small id='piuPB'></small><noframes id='piuPB'>

                  <legend id='piuPB'><style id='piuPB'><dir id='piuPB'><q id='piuPB'></q></dir></style></legend>

                  <i id='piuPB'><tr id='piuPB'><dt id='piuPB'><q id='piuPB'><span id='piuPB'><b id='piuPB'><form id='piuPB'><ins id='piuPB'></ins><ul id='piuPB'></ul><sub id='piuPB'></sub></form><legend id='piuPB'></legend><bdo id='piuPB'><pre id='piuPB'><center id='piuPB'></center></pre></bdo></b><th id='piuPB'></th></span></q></dt></tr></i><div id='piuPB'><tfoot id='piuPB'></tfoot><dl id='piuPB'><fieldset id='piuPB'></fieldset></dl></div>
                  <tfoot id='piuPB'></tfoot>

                    <tbody id='piuPB'></tbody>

                      <bdo id='piuPB'></bdo><ul id='piuPB'></ul>