Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1484

QML Hello World doesn't work on Windows 10

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Cannot Reproduce
    • Affects Version/s: 5.15.2, 6.0.0
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:
      None

      Description

      I've tried to run a hello world with QML in a laptop with Windows 10. The program is executed but you have a white screen and an error message "Network error" in the console.
       On Linux work properly but it's impossible on Windows 10. I tried changing path object or changing the QUrl method but I had the same result,

      QML file -> hello.qml

      import QtQuick 2.0
      
      Rectangle {
          width: 200
          height: 200
          color: "green"
      
          Text {
              text: "Hello world"
              anchors.centerIn: parent
          }
      
          TextInput {
              id: textInput1
              x: 60
              y: 112
              width: 80
              height: 20
              text: qsTr("Introduzca texto")
              font.pixelSize: 12
          }
      }
      
      

      Python file -> hello_qml.py

      import sys
      from pathlib import Path, WindowsPath
      from PySide2.QtWidgets import QApplication
      from PySide2.QtQuick import QQuickView
      from PySide2.QtCore import QUrl
      
      app = QApplication(sys.argv)
      
      qml_file = str(Path(__file__).parents[0] / 'hello.qml')
      # qml_file = str(WindowsPath(__file__).parents[0] / 'hello.qml')
      print(f'qml file = {qml_file}')
      
      # url = QUrl(qml_file)
      url = QUrl.fromLocalFile(qml_file)
      
      view = QQuickView()
      view.setSource(url)
      view.show()
      
      sys.exit(app.exec_())
      
      

      Thanks in advance

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            crmaurei Cristian Maureira-Fredes
            Reporter:
            crisconru Cristóbal Contreras Rubio
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes