, aber ich erhalte falsch im Schritt, die .QML -Datei als .ui im QT -Ersteller zu speichern. Der Fehler ist „ein Fehler beim Lesen einer UI -Datei mit einer Zeile und einer Spalte: Markierung muss starten“
PS:
QT Creator 15.0.1
basierend auf qt 6.8.1 (MSVC 2022, x86_64) < /p>
Bauton 225 2025 13:47:55 < /p> , aus dem 22. Januar 2025 13:47:55 < /p> , am 22. Januar 2025 13:47:55 < /p> , aus dem 225. Januar 2025 13:47:55 < /p>
, aus 225.225. 0855A2E14D < /p>
QT Design Studio 4.7 (4.7.0)
Basierend auf QT 6.8.2 (MSVC 2022, x86_64) < /p>
, gebaut am Februar, 15 2025 13:18:04 < /p>
Eine .ui.qml -Datei von Qt Design Studio in eine .PY -Datei umfasst mehrere Schritte:
Schritt 1. Dies ist der screen01.ui.qml < /p>
Code: Select all
/*
This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only.
It is supposed to be strictly declarative and only uses a subset of QML. If you edit
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick
import QtQuick.Controls
import UIDesign
Rectangle {
id: rectangle
width: Constants.width
height: Constants.height
color: Constants.backgroundColor
Button {
id: button
text: qsTr("Press me")
anchors.verticalCenter: parent.verticalCenter
checkable: true
anchors.horizontalCenter: parent.horizontalCenter
Connections {
target: button
onClicked: animation.start()
}
}
Text {
id: label
text: qsTr("Hello UIDesign")
anchors.top: button.bottom
font.family: Constants.font.family
anchors.topMargin: 45
anchors.horizontalCenter: parent.horizontalCenter
SequentialAnimation {
id: animation
ColorAnimation {
id: colorAnimation1
target: rectangle
property: "color"
to: "#2294c6"
from: Constants.backgroundColor
}
ColorAnimation {
id: colorAnimation2
target: rectangle
property: "color"
to: Constants.backgroundColor
from: "#2294c6"
}
}
}
states: [
State {
name: "clicked"
when: button.checked
PropertyChanges {
target: label
text: qsTr("Button Checked")
}
}
]
}
< /code>
Ich speichere den screen01.ui.qml als screen01.qml < /p>
** Schritt 2: ** Öffnen Sie in QT Creator: Öffnen Sie die .qml -Datei in qt creator.QML module not found (UlDesign).
Import paths:D:/0T/Tools/QtCreator/bin/qm
For qmake projects, use the QML lMPORT PATH variable to add import paths.For Qbs projects, declare and set a qmllmportPaths property in your product to add import paths.For qmlproject projects, use the importPaths property to add import paths.For CMake projects, make sure QML IMPORT PATH variable is in CMakeCache.txt.For qmlRegister. calls, make sure that you define the Module URl as a string literal
< /code>
Ich bin ein neuer Benutzer von QT. Ich denke, das Uidesign -Modul ist in den verschiedenen Schritten nicht wichtig und nützlich. Also deliere ich diese Zeile, um diese Nachricht zu ignorieren. Dieser Schritt ist entscheidend, da das Format von .ui.qml aus Qt Design Studio nicht direkt mit den Tools kompatibel ist, die zum Generieren von Python -Code verwendet werden. Dieser Fehler trat auf: < /p>
An error occurred when reading a UI file with 1 row and 1 column: Marking needs to start
< /code>
Ich kann nicht verstehen, welchen Fehler in der Spalte 1 Zeile und 1. Dies ist die Datei screen01.ui. < /P>
/*
This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only.
It is supposed to be strictly declarative and only uses a subset of QML. If you edit
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick
import QtQuick.Controls
Rectangle {
id: rectangle
width: Constants.width
height: Constants.height
color: Constants.backgroundColor
Button {
id: button
text: qsTr("Press me")
anchors.verticalCenter: parent.verticalCenter
checkable: true
anchors.horizontalCenter: parent.horizontalCenter
Connections {
target: button
onClicked: animation.start()
}
}
Text {
id: label
text: qsTr("Hello UIDesign")
anchors.top: button.bottom
font.family: Constants.font.family
anchors.topMargin: 45
anchors.horizontalCenter: parent.horizontalCenter
SequentialAnimation {
id: animation
ColorAnimation {
id: colorAnimation1
target: rectangle
property: "color"
to: "#2294c6"
from: Constants.backgroundColor
}
ColorAnimation {
id: colorAnimation2
target: rectangle
property: "color"
to: Constants.backgroundColor
from: "#2294c6"
}
}
}
states: [
State {
name: "clicked"
when: button.checked
PropertyChanges {
target: label
text: qsTr("Button Checked")
}
}
]
}
< /code>
** STEP4: ** In .py konvertieren: Verwenden Sie das Pyuic -Tool, das Teil von PYQT oder Pyside ist, um die .ui -Datei in eine .py -Datei zu [url=viewtopic.php?t=12659]konvertieren.[/url] Die Befehlszeilensyntax lautet wie folgt: < /p>
pyuic5 -o output_file.py input_file.ui
< /code>
Ich denke, der screen01.ui ist nicht korrekt. Denn in diesem Schritt trat der gleiche Fehler auf: < /p>
An error occurred when reading a UI file with 1 row and 1 column: Marking needs to start