Reputation: 7989
There is a QML ToolBar
. I can build/run the app with Qt 5.9 without any error. But when building/running the app with Qt 5.11, I received this error:
QML EnableButton: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead.
The above error occurs at the ToolbarButton
declarations at in tool-bar code:
ToolBar {
id: mainToolBar
anchors.fill: parent
style: ToolBarStyle {
padding.top: 0
padding.bottom: 0
padding.right: 0
padding.left: 0
background: Rectangle {
implicitHeight: newButton.height
color: editorContent.itemBackgroundColor
}
}
RowLayout {
spacing: 0
ToolbarButton {
id: newButton
enabledIconSource: "images/new.png"
tooltip: qsTr("New") + editorScene.emptyString
onEnabledButtonClicked: editorContent.fileNew()
Layout.alignment: Qt.AlignLeft
}
ToolbarButton {
enabledIconSource: "images/load.png"
tooltip: qsTr("Load (Ctrl + O)") + editorScene.emptyString
onEnabledButtonClicked: editorContent.fileLoad()
Layout.alignment: Qt.AlignLeft
}
// ...
// ...
I don't have any anchors
in the ToolbarButton
code whatsoever, instead, I'm actually using Layout.alignment
in ToolbarButton
code. I don't understand why such an error is thrown.
The whole project I'm trying to build with Qt 5.11 is available here:
https://github.com/qt-labs/qt3d-editor
To resolve the error, I replaced anchors
with Layout.alignment
, but it didn't help.
Upvotes: 2
Views: 11380
Reputation: 1906
The anchors
is in the ToolbarButton implementation. It's usually not a good idea to reference somewhere outside a component implementation, especially do any anchoring. It should be done by layout (e.g. Toolbar). Your ToolbarButton doesn't support vertical toolbars.
Upvotes: 3