QML - Control border width and color on any one side of Rectangle element -


currently had requirement of drawing delegate rectangle of listview control. able draw series of rectangle either horizontal or vertical within list view problem border of rectangle. border width @ intersect point of adjacent rectangle of twice width.

the delegate rectangle nothing qt quick rectangle element.

is possible limit border width on 1 side of rectangle alone?

is possible change color on 1 side? (something similar qlineedit - can control border width , color respect sides)

regards, santhosh.

you can make custom border element :

customborder.qml

import qtquick 1.0  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     } } 

main.qml

import qtquick 1.0  rectangle {     width:  500     height: 500     color: "grey"      rectangle     {         anchors.centerin: parent         width : 300         height: 300         color: "pink"          customborder         {             commonborderwidth: 3             bordercolor: "red"         }     }       rectangle     {         anchors.centerin: parent         width : 200         height: 200         color: "green"          customborder         {             commonborder: false             lborderwidth: 10             rborderwidth: 0             tborderwidth: 0             bborderwidth: 0             bordercolor: "red"         }     }       rectangle     {         anchors.centerin: parent         width : 100         height: 100         color: "yellow"          customborder         {             commonborder: false             lborderwidth: 0             rborderwidth: 0             tborderwidth: 10             bborderwidth: 10             bordercolor: "blue"         }     }  } 

in example have used custom element make different rectangles have border on all, 1 or 2 sides.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -