Qt Creator Documentation 2.8.0

Contents

QML Switch Element

A switch button with a text label More...

Properties

Detailed Description

The Switch type provides an image button with a text label that can be styled using images and text, and has an on and off state.

Here is a simple Switch:

 import QtQuick 1.1
 import "components"

 Switch {
     id: switch1
     width: 60
     height: 40
     on: false
     textOff: "Off"
     textOn: "On"
     textOnBold: false
     textOnFontFamily: "Arial"
     textOffFontFamily: "Arial"
     textOnFontSize: 14
     textOffFontSize: 14
     imageOn: "images/internal_button_up.bmp"
     imageOff: "images/internal_button_dn.bmp"
     textOnColor: "#000000"
     textOffColor: "#000000"
     textOffBold: false

     onButtonClick: console.debug(on);
     onButtonPress: console.debug(on);
     onButtonRelease: console.debug(on);
 }

Property Documentation

height : int

The height of the switch button.


imageOff : url

The source image for the switch off state.


imageOn : url

The source image for the switch on state.


on : bool

A boolean property to determine the state of the switch.


textOff : string

The text for the switch off state.


textOffBold : bool

Determines if the text for the switch off state should be bold.


textOffColor : string

The color of the text for the switch off state.


textOffFontFamily : string

The font family of the text for the switch off state.


textOffFontSize : int

The font pixel size of the text for the switch off state.


textOn : string

The text for the switch on state.


textOnBold : bool

Determines if the text for the switch on state should be bold.


textOnColor : string

The color of the text for the switch on state.


textOnFontFamily : string

The font family of the text for the switch on state.


textOnFontSize : int

The font pixel size of the text for the switch on state.


value : string

A value that can be assigned to the on state.


width : int

The width of the switch button.