The LineItem can be used to display colored single and segmented lines. More...
Import Statement: | import Felgo 4.0 |
Since: | Felgo 2.0.4 |
Inherits: |
The LineItem is an element which can display primitive lines. The lines can have different segments and can be colored.
Following examples show different use cases of the LineItem.
This example demonstrates how to use the LineItem to create a simple white line with thickness 1 from one point to another.
import Felgo import QtQuick GameWindow { Scene { LineItem { anchors.centerIn: parent points: [ {"x": 0, "y": 0}, {"x": 10, "y": 10} ] } } }
This example demonstrates how to connect lines to another object which can be moved.
import Felgo import QtQuick GameWindow { Scene { id: scene LineItem { color: "green" points: [ {"x":0, "y":0}, {"x":mousePos.x, "y":mousePos.y} ] } LineItem { color: "red" points: [ {"x":scene.width, "y":scene.height}, {"x":mousePos.x+20, "y":mousePos.y+20} ] } Rectangle { id: mousePos width: 20 height: 20 } MouseArea{ anchors.fill: parent onPositionChanged: { mousePos.x = mouseX mousePos.y = mouseY } } } }
See also PolygonItem.
color : color |
This property is used to define the color of the line. The default value is black.
lineWidth : int |
This property is used to define the thickness of the line. The default value is 1.
points : variant |
This property is used to provide the segment points of the line. Each point needs a x
and y
property stated as map properties. You can add as many points in the point array as you like.
import Felgo import QtQuick GameWindow { Scene { LineItem { points: [ {"x": 0, "y": 0}, {"x": 40, "y": 10}, {"x": 100, "y": 106}, {"x": 20, "y": 310} ] } } }
rounded : bool |
This property is used enable rounded edges at the start and the end of the line. The default value is false.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: