CDPBaseComboBox Class
The Combo Box widget is used to display and change values/texts of CDP objects. More...
Header: | #include <CDPBaseWidgets/CDPBaseComboBox.h> |
Inherits: | StateChanger, CDPBaseCom, CDPBaseControlVisible, |
Inherited By: |
Public Types
enum | OutOfBoundsAction { defaultValueFirst, defaultValueLast, addValueFirst, addValueLast } |
typedef | StylingSvgMap |
enum | StylingType { NoFile, CSS, SVG } |
Properties
|
|
Public Functions
CDPBaseComboBox(QWidget *parent = 0) | |
virtual | ~CDPBaseComboBox() |
int | confirmTimeOut() |
QString | cssFile() |
virtual double | disabledStateOpacity() const |
const QFont & | font() |
virtual QColor | fontColor() |
OutOfBoundsAction | getOutOfBoundsAction() |
StylingType | getStylingType() |
bool | getSvgOverwriteGeneratedFiles() |
bool | getUseIndex() |
QString | icon() |
QColor | index0() |
QColor | index1() |
QColor | index2() |
QColor | index3() |
bool | isCssStyling() |
bool | isSvgStyling() |
virtual QString | keyPadTitle() |
virtual CDPBasePadLauncher::GlobalDialog | keyPadType() |
bool | noSystemBackground() |
bool | opaquePaintEvent() |
QString | routing() |
void | setConfirmTimeOut(int ms) |
void | setCssFile(QString cssFile) |
virtual void | setDisabledStateOpacity(double opacity) |
void | setFont(const QFont &font) |
virtual void | setFontColor(QColor fontColor) |
virtual void | setIQtCDPPointer(IQtCDP *pIQtCDP) |
void | setIcon(QString icon) |
void | setIndex0(QColor fontColor) |
void | setIndex1(QColor fontColor) |
void | setIndex2(QColor fontColor) |
void | setIndex3(QColor fontColor) |
virtual void | setKeyPadTitle(QString title) |
virtual void | setKeyPadType(CDPBasePadLauncher::GlobalDialog dialog) |
void | setNoSystemBackground(bool enable) |
void | setOpaquePaintEvent(bool enable) |
int | setOutOfBoundsAction(OutOfBoundsAction action) |
void | setRouting(QString routing) |
void | setStylingType(StylingType type) |
void | setSvgFile(const QString &svg) |
void | setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles) |
void | setUpdateOnSlotOnly(bool update) |
void | setUseIndex(bool indx) |
void | setUseIndexColor(bool indexColor) |
QString | svgFile() |
bool | updateOnSlotOnly() |
bool | useIndexColor() |
int | widgetStyle() |
- 3 public functions inherited from StateChanger
- 17 public functions inherited from CDPBaseCom
- 4 public functions inherited from CDPBaseControlVisible
Public Slots
virtual void | handleVisible(double visible) |
virtual void | hideWidget() |
virtual const QStringList & | pushRoutables() const |
void | resetToCdp() override |
void | sendToCdp() override |
void | setCurrentIndex(int index) |
virtual void | setCurrentTextWithinBounds(const QString &text) |
virtual void | setInCommand(bool cmd) |
virtual void | setSmoothPixmap(bool smooth) |
virtual void | setValue(double value) |
virtual void | setValue(int value) |
virtual bool | setValue(QString value, bool bScale) |
virtual void | setWidgetFont(const QString &font) |
virtual void | setWidgetStyle(int style) |
virtual void | setWidgetTheme(const QString &theme) |
void | showPopup() override |
virtual void | showWidget() |
Signals
void | indexOutOfBounds(bool outOfBounds) |
void | indexWithinBounds(bool withinBounds) |
void | pushRoutablesChanged(const QStringList &pushers) |
Protected Functions
QString | addUrl(QString path) |
virtual CDPBaseLineEdit * | cdpLineEdit() |
void | changeEvent(QEvent *e) override |
QString | generatedStyleSheet() |
void | loadSvg() |
QSize | minimumSizeHint() const override |
void | prosessOutOfBoundsValue(QString value) |
void | updateTextColorFromSvg() |
- 4 protected functions inherited from CDPBaseCom
- 1 protected function inherited from CDPBaseControlVisible
Protected Slots
virtual void | connectCurrentIndexChanged() |
QString | getCurrentIcon() |
void | initDeprecated() |
virtual void | initDynamicFontColors() |
virtual void | sendStateChanged(const QString &text) |
virtual void | sendValueToCdp(int index) |
virtual void | updateCDP(int value) |
void | updateFontColor(int index) |
void | updateTextFromCdp() |
Additional Inherited Members
- 2 static public members inherited from CDPBaseCom
Detailed Description
The Combo Box widget is used to display and change values/texts of CDP objects.
The CDPBaseComboBox can be customized using css, svg files or using the stylesheet. 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: You can select to send/receive index numbers or content by editing the cdpUseIndexNr property. The property will be set to false automatically if receiving strings that exist in the item list. There is one exception. The string that is sent to indicate no connection, (--), can be included at any index without affecting the cdpUseIndexNr property.
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 CDPComboBox can use the standard svg structure of the CDPBaseSpinBox. It can also have its own svg file following the naming conventions listed below.
Note: Elements that are written with pointy brackets, like < Path >, can be given any name. Avoid cdp prefix as these are special to the parser.
svg └─── Layer1 ├─── cdpText (text) ├─── cdpMenuColor (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.
Property | Type | Description |
---|---|---|
cdpText | text | The color and size of the font to be used on the unit text. At the moment we onely use the color from this layer. |
cdpMenuColor | text | Text color is used on menu background when present. |
cdpBorderMarginTopLeft | Transparent rect/path | Transparent rectangle that specifies the right border margin by its width and the bottom border margin by its height. |
cdpBorderMarginBottomRight | Transparent rect/path | Transparent rectangle that specifies the right border margin by its width and the bottom border margin by its height. |
cdpBackground | rect or an element group containing a rect | The cdpBackground should contain the actual background graphics. |
cdpButtonDown | rect or an element group containing a rect | The cdpButtonDown should contain the actual button graphics. |
cdpButtonDownPressed | rect or an element group containing a rect | The cdpButtonDownPressed should contain the graphics to show when the button is pressed. |
cdpButtonDownDisabled | rect or an element group containing a rect | The cdpButtonDownDisabled should contain the actual button graphics. |
cdpIconDown | rect or an element group containing a rect | The 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. |
Note: CDPBaseComboBox generates raster images from svg as described here.
To see where the images are stored, right-click on the widget. Select "Change styleSheet..." and have a look at the paths of the border images.
Member Type Documentation
enum CDPBaseComboBox::OutOfBoundsAction
This enum type specifies value out of bounds actions:
Constant | Value | Description |
---|---|---|
CDPBaseComboBox::defaultValueFirst | 0 | Show the first item in the list. |
CDPBaseComboBox::defaultValueLast | 1 | Show the last item in the list. |
CDPBaseComboBox::addValueFirst | 2 | Add the value at first of the list. |
CDPBaseComboBox::addValueLast | 3 | Add the value at end of the list |
typedef CDPBaseComboBox::StylingSvgMap
enum CDPBaseComboBox::StylingType
This enum type specifies what styling type to use:
Constant | Value | Description |
---|---|---|
CDPBaseComboBox::NoFile | 0 | No styling file. |
CDPBaseComboBox::CSS | 1 | Style by css file. |
CDPBaseComboBox::SVG | 2 | Style by SVG file. |
Property Documentation
cdpOfflineValue : const double
This property holds the value to show when communication is offline and cdpOfflineValueEnabled is set to true.
The property has no effect when cdpOfflineValueEnabled is set to false
.
See also cdpOfflineValueEnabled.
cdpOfflineValueEnabled : const bool
This property holds whether or not to show cdpOfflineValue when communication is offline.
Setting the property to false
will make the widget keep/show the last value when communication is down.
See also cdpOfflineValue.
cdpRouting : QString
This property holds the routing to the CDP object that the widget is to connect and control.
The routing is bi-directional. This means that if two combo boxes or other widgets are routed to control the same remote object, they will all receive and show new values when the remote value is changed.
Access functions:
QString | routing() |
void | setRouting(QString routing) |
cdpTimeoutMs : int
This property holds the time to wait before confirming the combobox selection.
If there is no signal at the specified route, default value is 0.0 .
Note: This property is ignored if cdpRouting is not set.
Access functions:
int | confirmTimeOut() |
void | setConfirmTimeOut(int ms) |
cdpUpdateOnSlotOnly : bool
This property holds whether to send a value to the routed CDP object when done editing or only when triggered by the sendToCdp slot function.
Setting this property to true
allows for use in settings dialogs where you want to be able to edit values without sending them to the control system. Then, when done editing, the user can decide whether to send or revert the changes by clicking buttons connected to sendToCdp or resetToCdp.
Note that multiple widgets, that support cdpUpdateOnSlotOnly, can be placed/grouped in a container widget to avoid Signal and Slot connections to all of them. The container has slots similar to sendToCdp and resetToCdp that will execute on all child widgets.
Access functions:
bool | updateOnSlotOnly() |
void | setUpdateOnSlotOnly(bool update) |
See also resetToCdp and sendToCdp.
cdpUseIndexNr : bool
This property holds whether to use the index value of an item in the list to send to the cdp signal instead of the actual value noted in the list.
Note: This has to be unchecked when the combobox is used to send text to a cdpProperty.
Access functions:
bool | getUseIndex() |
void | setUseIndex(bool indx) |
See also index0, index1, index2, and index3.
cdpVisibleRouting : const QString
This property holds the full path of the signal/parameter that controls the “visible” property.
Note: Values not equal to 1 are considered false.
See also visible.
cssFile : QString
This property holds the css file to use for customization.
http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qspinbox
Access functions:
QString | cssFile() |
void | setCssFile(QString cssFile) |
See also svgFile.
currentIndex : int
This property holds the value of the current index.
Access functions:
void | setCurrentIndex(int index) |
disabledStateOpacity : double
This property holds the level of opacity for the widget in the disabled state.
The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent).
Setting this property configures a fixed opacity that can be different than the global opacity used in other widgets.
Access functions:
virtual double | disabledStateOpacity() const |
virtual void | setDisabledStateOpacity(double opacity) |
font : QFont
This property holds the font to be used in widget.
Access functions:
const QFont & | font() |
void | setFont(const QFont &font) |
fontColor : QColor
This property holds the font color.
Note: If set, this overrides the text color from SVG file and the entire code received from CSS file.
Access functions:
virtual QColor | fontColor() |
virtual void | setFontColor(QColor fontColor) |
icon : QString
This property holds the icon to show on the “Down” button.
If stylingType is set to SVG, this option overrides the icon parsed from the svg file.
Access functions:
QString | icon() |
void | setIcon(QString icon) |
See also stylingType and svgFile.
index0 : QColor
This property holds the color to show if index 0 is selected.
Access functions:
QColor | index0() |
void | setIndex0(QColor fontColor) |
See also index1, index2, index3, and useIndexColor.
index1 : QColor
This property holds the color to show if index 1 is selected.
Access functions:
QColor | index1() |
void | setIndex1(QColor fontColor) |
See also index0, index2, index3, and useIndexColor.
index2 : QColor
This property holds the color to show if index 2 is selected.
Access functions:
QColor | index2() |
void | setIndex2(QColor fontColor) |
See also index0, index1, index3, and useIndexColor.
index3 : QColor
This property holds the color to show if index 3 is selected.
Access functions:
QColor | index3() |
void | setIndex3(QColor fontColor) |
See also index0, index1, index2, and useIndexColor.
noSystemBackground : bool
This property holds whether the widget has a background.
Newly exposed areas are never filled with the background.
Access functions:
bool | noSystemBackground() |
void | setNoSystemBackground(bool enable) |
See also opaquePaintEvent.
opaquePaintEvent : bool
This property holds whether the widget is transparent.
Set true
to optimize painting when having no transparency in widget graphics This property should be set true
on all widgets that does not require transparency. It will prevent Qt from painting widgets behind current widget and thus increase performance.
Access functions:
bool | opaquePaintEvent() |
void | setOpaquePaintEvent(bool enable) |
See also visible and noSystemBackground.
outOfBoundsAction : OutOfBoundsAction
This property holds what to do if receiving a signal or property from a CDPObject that is not in the list.
Options are:
- Show the first item in the list
- Show the last item in the list
- Add the value at first of the list ( Careful if cdpUseIndexNr is set. )
- Add the value at end of the list ( Careful if cdpUseIndexNr is set. )
Access functions:
OutOfBoundsAction | getOutOfBoundsAction() |
int | setOutOfBoundsAction(OutOfBoundsAction action) |
See also cdpUseIndexNr.
padTitle : QString
This property holds the title of the input-pad.
Access functions:
virtual QString | keyPadTitle() |
virtual void | setKeyPadTitle(QString title) |
See also padType.
padType : CDPBasePadLauncher::GlobalDialog
This property holds which input pad is used for inserting a value manually.
Access functions:
virtual CDPBasePadLauncher::GlobalDialog | keyPadType() |
virtual void | setKeyPadType(CDPBasePadLauncher::GlobalDialog dialog) |
See also padTitle.
pushRoutables : const QStringList
Access functions:
virtual const QStringList & | pushRoutables() const |
Notifier signal:
void | pushRoutablesChanged(const QStringList &pushers) |
stylingType : StylingType
This property holds a selection of how to customize the widget.
Options are:
- "NoFile" - Don't use a file for customization
- "CSS" - Use a css file specified by cssFile property for customization
- "SVG" - Use a svg file specified by svgFile property for customization
Note: To customize in QtDesigner, set this property to "NoFile".
Access functions:
StylingType | getStylingType() |
void | setStylingType(StylingType type) |
svgFile : QString
This property holds the path to the svg file that styles the widget.
The path can be either to a resource or a file on disk.
Note: Resources can be overridden by files on disk with identical names.
Access functions:
QString | svgFile() |
void | setSvgFile(const QString &svg) |
See also cssFile.
svgOverwriteGeneratedFiles : bool
This property holds whether every time loadSvg() is called, the widget creates new png images from the svg file or not.
Access functions:
bool | getSvgOverwriteGeneratedFiles() |
void | setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles) |
See also svgFile.
useIndexColor : bool
This property holds whether to make the text change color depending on what index is shown.
Note: If set, this overrides the text color from SVG file, and the entire code received from CSS file.
Note: If index exceeds index3, the color of index0 is shown.
Access functions:
bool | useIndexColor() |
void | setUseIndexColor(bool indexColor) |
visible : const bool
This property holds whether to show the QWidget or not.
See also cdpVisibleRouting.
Member Function Documentation
CDPBaseComboBox::CDPBaseComboBox(QWidget *parent = 0)
Default constructs an instance of CDPBaseComboBox.
[virtual]
CDPBaseComboBox::~CDPBaseComboBox()
Destroys the instance of CDPBaseComboBox. The destructor is virtual.
[protected]
QString CDPBaseComboBox::addUrl(QString path)
[virtual protected]
CDPBaseLineEdit *CDPBaseComboBox::cdpLineEdit()
[protected]
void CDPBaseComboBox::changeEvent(QEvent *e)
[virtual protected slot]
void CDPBaseComboBox::connectCurrentIndexChanged()
[protected]
QString CDPBaseComboBox::generatedStyleSheet()
[protected slot]
QString CDPBaseComboBox::getCurrentIcon()
[virtual slot]
void CDPBaseComboBox::handleVisible(double visible)
[virtual slot]
void CDPBaseComboBox::hideWidget()
[signal]
void CDPBaseComboBox::indexOutOfBounds(bool outOfBounds)
[signal]
void CDPBaseComboBox::indexWithinBounds(bool withinBounds)
[protected slot]
void CDPBaseComboBox::initDeprecated()
[virtual protected slot]
void CDPBaseComboBox::initDynamicFontColors()
bool CDPBaseComboBox::isCssStyling()
bool CDPBaseComboBox::isSvgStyling()
[protected]
void CDPBaseComboBox::loadSvg()
[protected]
QSize CDPBaseComboBox::minimumSizeHint() const
[protected]
void CDPBaseComboBox::prosessOutOfBoundsValue(QString value)
[slot]
void CDPBaseComboBox::resetToCdp()
Executing this slot will reset the widget to the value of the routed CDP object.
The functionality is often used in settings dialogs to enable the user to edit values and then select whether to save or cancel the changes. To avoid value changes being sent instantly to the routed object, the property named cdpUpdateOnSlotOnly must be set to true
.
Note that the container widget has slots for reset and send that will execute resetToCdp and sendToCdp on all child widgets.
See also cdpUpdateOnSlotOnly and sendToCdp.
[virtual protected slot]
void CDPBaseComboBox::sendStateChanged(const QString &text)
[slot]
void CDPBaseComboBox::sendToCdp()
Executing this slot will make the widget send its value to the routed CDP object.
The functionality is often used in settings dialogs to enable the user to edit values and then select whether to save or cancel the changes. To avoid value changes being sent instantly to the routed object, the property named cdpUpdateOnSlotOnly must be set to true
.
Note that the container widget has slots for reset and send that will execute resetToCdp and sendToCdp on all child widgets.
See also cdpUpdateOnSlotOnly and resetToCdp.
[virtual protected slot]
void CDPBaseComboBox::sendValueToCdp(int index)
[virtual slot]
void CDPBaseComboBox::setCurrentTextWithinBounds(const QString &text)
This function will set the current index that equals the text argument. If no matching items exist, the text is handled according to the value configured in the outOfBoundsAction property.
[virtual]
void CDPBaseComboBox::setIQtCDPPointer(IQtCDP *pIQtCDP)
[virtual slot]
void CDPBaseComboBox::setInCommand(bool cmd)
[virtual slot]
void CDPBaseComboBox::setSmoothPixmap(bool smooth)
[virtual slot]
void CDPBaseComboBox::setValue(double value)
[virtual slot]
void CDPBaseComboBox::setValue(int value)
[virtual slot]
bool CDPBaseComboBox::setValue(QString value, bool bScale)
[virtual slot]
void CDPBaseComboBox::setWidgetFont(const QString &font)
[virtual slot]
void CDPBaseComboBox::setWidgetStyle(int style)
See also widgetStyle().
[virtual slot]
void CDPBaseComboBox::setWidgetTheme(const QString &theme)
[slot]
void CDPBaseComboBox::showPopup()
[virtual slot]
void CDPBaseComboBox::showWidget()
[virtual protected slot]
void CDPBaseComboBox::updateCDP(int value)
[protected slot]
void CDPBaseComboBox::updateFontColor(int index)
[protected]
void CDPBaseComboBox::updateTextColorFromSvg()
[protected slot]
void CDPBaseComboBox::updateTextFromCdp()
int CDPBaseComboBox::widgetStyle()
See also setWidgetStyle().
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.