Hello everyone,
after some years with QWidgets, i decided to join the "QML stream" and give QML a try.
Yet, i've run into problems i can't even really explain (is there any good Error-Handling for QML??).
Problem 1: adding a ToolButton to a ToolBar
import QtQuick 2.3
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
ApplicationWindow {
id: applicationWindow
width: 800
height: 600
title: "test"
toolBar: ToolBar {
id: mainWindowToolbar
RowLayout {
id: mainWindowToolbarLayout
anchors.fill: parent // problem 2
}
}
Component.onCompleted: {
Qt.createQmlObject('import QtQuick 2.0; Rectangle {color: "red"; width: 20; height: 20}',
mainWindowToolbarLayout,
"TestToolButton");
}
}
import QtQuick 2.3
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
ApplicationWindow {
id: applicationWindow
width: 800
height: 600
title: "test"
toolBar: ToolBar {
id: mainWindowToolbar
RowLayout {
id: mainWindowToolbarLayout
anchors.fill: parent // problem 2
}
}
Component.onCompleted: {
Qt.createQmlObject('import QtQuick 2.0; Rectangle {color: "red"; width: 20; height: 20}',
mainWindowToolbarLayout,
"TestToolButton");
}
}
To copy to clipboard, switch view to plain text mode
If i (re)start the application 3 times, it crashes 2/3 times and also throws an error: "Qt.createQmlObject(): Component is not ready".
Google told me that this one of the most unrelieable error message in QML.
Which brings us to Problem #3: in the documentation of Qt.createQmlObject it states that an QtScript error is thrown, so i encapsulated the Qt.createQmlObject part into an try and catch block - yet i have no idea how to retrieve the errors from that qmlErrors() function.
Problem 2: mainWindowToolbarLayout + "anchors.fill: parent" prints the following things into the output-console:
QML Item: Binding loop detected for property "layoutHeight"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitHeight""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitHeight"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitWidth"
"qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitHeight""
qrc:/qml/MainWindowUI:16:14: QML ToolBar: Binding loop detected for property "implicitHeight"
To copy to clipboard, switch view to plain text mode
What? The documentation isn't doing anything different?
What brings us to my final question:
is there any sane way to debug such things in QML?
Bookmarks