Problem with Rectangle border width
Solved
QML and Qt Quick
-
I am sure this has been asked before so sorry about that. Is it possible to make it so that the shared side is not a 2 pixel thick border? This looks awkward to me:
Row { id: titleColumn width: parent.width height: 90 Rectangle { id: nameTextContainer width: parent.width/2 height: parent.height border.width: 1 } Rectangle { id: typeTextContainer width: parent.width/2 height: parent.height border.width: 1 } }
-
Rectangle { id: leftRect anchors.fill: parent color: "red" width: parent.width / 2 height: parent.height border.width: 1 Rectangle { color: "yellow" width: parent.width / 2 border.width: 1 height: parent.height anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom } }
-
@guerinoni said in Problem with Rectangle border width:
anchors.fill: parent
width: parent.width / 2this 2 lines together make no sense to me
-
I figured out a way to do this. Well, someone else figured it out and I just applied a
Row
andRepeater
:Row { Repeater { model: 3 Rectangle { width: 100 height: 40 CustomBorder { borderColor: "black" } } } }
where
CustomBorder
is:Rectangle { property bool commonBorder : true property int lBorderwidth : 1 property int rBorderwidth : 1 property int tBorderwidth : 1 property int bBorderwidth : 1 property int commonBorderWidth : 1 z : -1 property string borderColor : "white" color: borderColor anchors { left: parent.left right: parent.right top: parent.top bottom: parent.bottom topMargin : commonBorder ? -commonBorderWidth : -tBorderwidth bottomMargin : commonBorder ? -commonBorderWidth : -bBorderwidth leftMargin : commonBorder ? -commonBorderWidth : -lBorderwidth rightMargin : commonBorder ? -commonBorderWidth : -rBorderwidth } }
which was created by @ Amit Tomar on SO.
I have a question. If instead of separating CustomBorder into it's own QML file. Is there a way I can use
Component
andLoader
s/t I can keep CustomBorder inside of main but still refrence it the same way ie:Rectangle { CustomBorder { } }
is that possible?