Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15
-
None
Description
Layouts presently restrict any use of anchors by children, with the following message: "Detected anchors on an item that is managed by a layout. This is undefined behaviour; use Layout.alignment instead"
While I can understand that such a warning makes sense, it is overly strict, and (particularly in the case of 'baseline', which does not have an appropriate replacement in 'alignment' terms), restrictive.
I think that the more correct thing to do would be something like QQuickAnchorsPrivate::checkHValid: check that the set anchor "directions" do not conflict with the layout's settings.
See the code below for an example.
import QtQuick 2.6 import QtQuick.Layouts 1.2 Item { RowLayout { Rectangle { id: marker width: 10 height: 10 color: "red" } Text { anchors.baseline: marker.verticalCenter text: "Hello, world" } } }