<< to CrossControl homepage

Support & Service Center

Access state of CCpilot VC hardware buttons from QML

Printer-friendly versionPrinter-friendly versionPDF versionPDF version

This application shows how the state of the hardware buttons on the CCpilot VC can be read and used in the GUI. When a button is pressed, the square next to the button changes color to a darker gray. A Behavior is used to fade the color change, making it look a little more interesting. The project use a class called HWButton to handle the states of the buttons. The class is then presented to the GUI which then can bind to the available properties in the class.
Rather then just check if the button state is True/False, an enum is used to represent the state of the button: Pressed or Released.

Extract from included *.qml-file:

// Rectangle which changes color based on the state of one of the hardware buttons.
	id: rect1
	height: parent.height/4
	width: height
	color: hwButton.button1 == HWButton.Pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
	border.color: "black"
	border.width: 1
	Behavior on color { ColorAnimation { duration: transitionTime } }
CCpilot VC hardware button GUI
Environment and Versions: 

LinX-Base v1.1 or newer

LinX Virtual Development Machine v1.1 Beta2 or newer

Package icon Project files15.75 KB