Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[SOLVED] About showing QWindow

$
0
0
hi guys i am working on a project that use PyQt5 and QML. i have this two files and they work: PyQt file: import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView   app = QApplication(sys.argv)   view = QQuickView() view.setSource(QUrl("example.qml")) view.show()   sys.exit(app.exec_()) and QML File: import QtQuick 2.0   Item {  id: root  width: 300; height: 100    Rectangle {   id: bg   anchors.fill: parent      color: "red"        Text {          id: helloworld          text: "Hello world!"          anchors.centerIn: parent          color: "White"          font.pointSize: 20      }  } } this project work. but question here: if instead of Item type that is instanced from QQuickItem, i use ApplicationWindow that instanced from QWindow, QQuickView can not show the window for me. i want to know that what Class of QtQuick should i use to show ApplicationWindow from PyQt? PyQt File: (same as before) import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView   app = QApplication(sys.argv)   view = QQuickView() view.setSource(QUrl("example.qml")) view.show()   sys.exit(app.exec_()) QML File: import QtQuick 2.0 import QtQuick.Controls 1.0   ApplicationWindow {  id: root  width: 300; height: 100  title: "my window"    Rectangle {   id: bg   anchors.fill: parent      color: "red"        Text {          id: helloworld          text: "Hello world!"          anchors.centerIn: parent          color: "White"          font.pointSize: 20      }  } } the error is : QQuickView only supports loading of root objects that derive from QQuickItem. thanks in advance

Viewing all articles
Browse latest Browse all 4972

Trending Articles