• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • GUI - CDP Widgets
  • CDPBaseComboBox

CDPBaseComboBox Class

The Combo Box widget is used to display and change values/texts of CDP objects. More...

Header: #include <CDPBaseComboBox>
Inherits: StateChanger, CDPBaseCom, CDPBaseControlVisible,
Inherited By:

CDPBaseTextSelector

  • List of all members, including inherited members

Public Types

enum OutOfBoundsAction { defaultValueFirst, defaultValueLast, addValueFirst, addValueLast }
typedef StylingSvgMap
enum StylingType { NoFile, CSS, SVG }

Properties

  • cdpOfflineValue : const double
  • cdpOfflineValueEnabled : const bool
  • cdpRouting : QString
  • cdpTimeoutMs : int
  • cdpUpdateOnSlotOnly : bool
  • cdpUseIndexNr : bool
  • cdpVisibleRouting : const QString
  • cssFile : QString
  • currentIndex : int
  • disabledStateOpacity : double
  • font : QFont
  • fontColor : QColor
  • icon : QString
  • index0 : QColor
  • index1 : QColor
  • index2 : QColor
  • index3 : QColor
  • noSystemBackground : bool
  • opaquePaintEvent : bool
  • outOfBoundsAction : OutOfBoundsAction
  • padTitle : QString
  • padType : CDPBasePadLauncher::GlobalDialog
  • pushRoutables : const QStringList
  • stylingType : StylingType
  • svgFile : QString
  • svgOverwriteGeneratedFiles : bool
  • useIndexColor : bool
  • visible : const bool

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.

Editable Mode

The combo box can be set to be editable, allowing the user to manually enter values.

When the editable property is true, the user can manually enter values in the combo box. This is also required for using the keypad, as the padType property depends on it to allow keypad input instead of a hardware keyboard.

The way user input is handled is determined by the insertPolicy property. For example, setting it to NoInsert allows temporary values to be entered without adding them to the combo box list.

Values received from the control system are managed by the outOfBoundsAction property. The received value will always be displayed when editable is set to true, even if it is not part of the predefined list.

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.

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.
cdpMenuColortextText color is used on menu background when present.
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.

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:

ConstantValueDescription
CDPBaseComboBox::defaultValueFirst0Show the first item in the list.
CDPBaseComboBox::defaultValueLast1Show the last item in the list.
CDPBaseComboBox::addValueFirst2Add the value at first of the list.
CDPBaseComboBox::addValueLast3Add the value at end of the list

typedef CDPBaseComboBox::StylingSvgMap

enum CDPBaseComboBox::StylingType

This enum type specifies what styling type to use:

ConstantValueDescription
CDPBaseComboBox::NoFile0No styling file.
CDPBaseComboBox::CSS1Style by css file.
CDPBaseComboBox::SVG2Style 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)

See also svgFile and cssFile.

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.

The pad title can only be set if a pad type is defined using the padType property. Since specifying a pad type requires the combo box to be editable, the editable property must also be set to true. See Editable Mode for details.

Access functions:

virtual QString keyPadTitle()
virtual void setKeyPadTitle(QString title)

See also padType.

padType : CDPBasePadLauncher::GlobalDialog

This property holds the input pad used for manual value entry.

This property requires the widget to be editable, which can be enabled by setting the editable property to true. When enabled, padType allows a keypad to be used instead of a hardware keyboard for entering values.

Clicking inside the combo box line edit opens the keypad, while clicking the combo box button still allows selecting from pre-defined values.

See Editable Mode for more details.

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)

See also svgFile and cssFile.

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)

See also svgFile and cssFile.

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().

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top