A label derived from Qt QLabel to display boolean values, strings, scalars and even vectors.
More...
|
| QuLabel (QWidget *w, Cumbia *cumbia, const CuControlsReaderFactoryI &r_fac) |
| Constructor with the parent widget, an engine specific Cumbia implementation and a CuControlsReaderFactoryI interface. More...
|
|
| QuLabel (QWidget *w, CumbiaPool *cumbia_pool, const CuControlsFactoryPool &fpool) |
| Constructor with the parent widget, CumbiaPool and CuControlsFactoryPool More...
|
|
virtual | ~QuLabel () |
|
QString | source () const |
|
CuContext * | getContext () const |
| returns the pointer to the CuContext More...
|
|
bool | displayUnitEnabled () const |
| returns true if the display unit is shown beside the value, false otherwise More...
|
|
QString | displayUnit () const |
| returns the display unit read by the configuration properties at initialization time. More...
|
|
QuPalette | quPalette () const |
| returns the QuPalette currently used More...
|
|
void | setQuPalette (const QuPalette &colors) |
| set a custom QuPalette to change the string/color association More...
|
|
void | onUpdate (const CuData &d) |
|
| QuLabelBase (QWidget *parent) |
|
| QuLabelBase (const QString &text, QWidget *parent) |
|
virtual | ~QuLabelBase () |
|
void | setBackground (const QColor &background) |
| set the background color of the label More...
|
|
void | setBorderColor (const QColor &border) |
| changes the border color More...
|
|
void | setDecoration (const QColor &background, const QColor &border) |
| changes the colors for the decoration of the label More...
|
|
double | borderWidth () const |
| returns the width, in pixels, of the colored border that is drawn around the label More...
|
|
void | setEnumDisplay (int val, const QString &text, const QColor &c) |
|
int | maximumLength () const |
| returns the maximum length of the displayed string More...
|
|
QSize | minimumSizeHint () const override |
| reimplements QLabel::minimumSizeHint to ensure there is enough space to draw the decorations on the border More...
|
|
QSize | sizeHint () const override |
|
int | heightForWidth (int w) const override |
|
bool | hasHeightForWidth () const override |
|
bool | drawInternalBorder () const |
| if enabled, an external and an internal border are drawn More...
|
|
QString | format () const |
| returns the format used to represent a number, or an empty string if no format is specified More...
|
|
virtual | ~CuContextI () |
|
virtual CuContext * | getContext () const =0 |
| Return a reference to the CuContext in use. More...
|
|
A label derived from Qt QLabel to display boolean values, strings, scalars and even vectors.
- Colors and strings can be associated to boolean values.
- Scalar numbers and strings can be displayed by QuLabel.
- Vectors are usually displayed only partially, according to the number of maximum characters allowed by setMaximumLength
Connection is initiated with setSource. When new data arrives, it is displayed and the newData signal is emitted. A propertyReady signal is provided for convenience and emitted only once at configuration time.
- Display enumeration values (if supported by the engine)
- If the underlying engine supports a configuration property named values, the list of strings is used to associate a value to a label. Likewise, if the engine supports a colors property, the list of colors is used to associate a value to a color. The values and colors properties, if available, are extracted at configuration time into a std::vector of std::string. The value of the source is used as index to pick up the label and the color from the vectors. Indexes start from zero. Labels are displayed as they are, while color strings are mapped through QuPalette into QColor. The QuPalette used is accessible through quPalette and setQuPalette.
getContext returns a pointer to the CuContext used as a delegate for the connection.
void QuLabel::setQuPalette |
( |
const QuPalette & |
colors | ) |
|
set a custom QuPalette to change the string/color association
- Parameters
-
colors | a new QuPalette that replaces the current one |
QuPalette maps color names to QColor colors. You can use this method as a trick to change the color for a state represented by the label. For example, if normally an OK state is associated to "green", you can set a custom palette so that the "green" color string is mapped into white color. In the following example, white color is used with the green key:
QuPalette myPalette = stateWidget->quPalette();
myPalette["green"] = QColor(Qt::white);
stateWidget->setQuPalette(myPalette);
a map associating a color name to a QColor
Definition: qupalette.h:35
Altering the QuPalette of a QuLabel (or a QuLed) is useful when a given state is associated to a predefined color (e.g. ON:green, OFF:white, ALARM:yellow, FAULT:red) and you want different combinations. Cumbia engines must store a state_color key/value pair in the CuVariant data delivered by the onUpdate method when the engine itself handles a *"s"* data type.
- See also
- quPalette