CDPBaseTextSelector Class

The Text Selector displays different texts based on numeric values. More...

Header: #include <CDPBaseTextSelector>
Inherits: CDPBaseComboBox

Properties

Public Functions

CDPBaseTextSelector(QWidget *parent)
virtual ~CDPBaseTextSelector()
virtual Qt::Alignment alignment()
virtual void mousePressEvent(QMouseEvent *ev)
virtual void setAlignment(Qt::Alignment alignment)
virtual void setUserEditable(bool editable)
virtual bool userEditable()

Reimplemented Public Functions

virtual QColor fontColor()
virtual void setFontColor(QColor fontColor)

Additional Inherited Members

Detailed Description

The Text Selector displays different texts based on numeric values.

Unlike the CDPBaseComboBox, this widget is read only and can not be changed by user clicks. Note that the above picture shows four different widget states (four widget instances showing different indexes).

Texts are added, removed and rearranged by right-clicking the widget and selecting “Edit Items...” from the context menu. Click on the green plus sign to add text items and note that the order is identical to the signal value for selecting it. Note that we can select to send/receive index numbers or content by editing the cdpUseIndexNr property, inherited from CDPBaseComboBox.

Note that the widget inherits CDPBaseComboBox and thus all of its properties. Some default settings is necessary to make the widget function as intended.

Styling by SVG

Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).

The CDPBaseTextSelector can use the standard svg structure of the CDPBaseComboBox. It can also have its own svg file following the naming conventions listed below.

svg
└─── Layer1
  ├─── cdpText                    (text)
  ├─── cdpBorderMarginTopLeft     (transparent rect/path)
  ├─── cdpBorderMarginBottomRight (transparent rect/path)
  ├─── cdpBackground              (element group)
  ├─── cdpButtonDown              (element group)
  ├─── cdpButtonDownPressed       (element group)
  ├─── cdpButtonDownDisabled      (element group)
  └─── cdpIconDown                (element group)
               ├─── < Path >      (transparent rect/path)
               └─── < Group >     (background graphics)

The following table explains the named elements in more detail.

PropertyTypeDescription
cdpTexttextThe color and size of the font to be used on the unit text. At the moment we onely use the color from this layer.
cdpBorderMarginTopLeftTransparent rect/pathTransparent rectangle that specifies the right border margin by its width and the bottom border margin by its height.
cdpBorderMarginBottomRightTransparent rect/pathTransparent rectangle that specifies the right border margin by its width and the bottom border margin by its height.
cdpBackgroundrect or an element group containing a rectThe cdpBackground should contain the actual background graphics.
cdpButtonDownrect or an element group containing a rectThe cdpButtonDown should contain the actual button graphics.
cdpButtonDownPressedrect or an element group containing a rectThe cdpButtonDownPressed should contain the graphics to show when the button is pressed.
cdpButtonDownDisabledrect or an element group containing a rectThe cdpButtonDownDisabled should contain the actual button graphics.
cdpIconDownrect or an element group containing a rectThe cdpButtonDown should contain the actual button graphics. To ensure that the svg parser gets the correct background size (and aspect ratio), we have to place a transparent rect along with the graphics within a group element.

Property Documentation

alignment : Qt::Alignment

This property holds the alignment of the text.

Access functions:

virtual Qt::Alignment alignment()
virtual void setAlignment(Qt::Alignment alignment)

editable : bool

This property holds whether to enable editing of the text.

Access functions:

virtual bool userEditable()
virtual void setUserEditable(bool editable)

Member Function Documentation

CDPBaseTextSelector::CDPBaseTextSelector(QWidget *parent)

Default constructs an instance of CDPBaseTextSelector.

[virtual] CDPBaseTextSelector::~CDPBaseTextSelector()

Destroys the instance of CDPBaseTextSelector. The destructor is virtual.

[virtual] QColor CDPBaseTextSelector::fontColor()

See also setFontColor().

[virtual] void CDPBaseTextSelector::mousePressEvent(QMouseEvent *ev)

[virtual] void CDPBaseTextSelector::setFontColor(QColor fontColor)

See also fontColor().