• 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
  • CDPBaseSpinBox

CDPBaseSpinBox Class

The Spin Box widget is used to display and change numeric values of either signals or parameters from a CDPObject. It can be customized using css, svg files or using the stylesheet. More...

Header: #include <CDPBaseSpinBox>
Inherits: StateChanger, CDPBaseCom, CDPBaseControlVisible,
  • List of all members, including inherited members

Public Types

typedef StylingSvgMap
enum StylingType { NoFile, CSS, SVG }

Properties

  • cdpOfflineValue : const double
  • cdpOfflineValueEnabled : const bool
  • cdpRouting : QString
  • cdpTabToConfirm : bool
  • cdpTimeoutMs : int
  • cdpUpdateOnSlotOnly : bool
  • cdpVisibleRouting : const QString
  • cssFile : QString
  • disabledStateOpacity : double
  • font : QFont
  • iconDown : QString
  • iconUp : QString
  • maxValue : double
  • maximum : const double
  • minValue : double
  • minimum : const double
  • noSystemBackground : bool
  • numPad : bool
  • opaquePaintEvent : bool
  • outOfRange : const bool
  • postfix : QString
  • precision : int
  • pushRoutables : const QStringList
  • stylingType : StylingType
  • svgFile : QString
  • svgFont : bool
  • svgOverwriteGeneratedFiles : bool
  • visible : const bool

Public Functions

CDPBaseSpinBox(QWidget *parent = 0)
virtual ~CDPBaseSpinBox()
int confirmTimeOut()
QString cssFile()
virtual double disabledStateOpacity() const
const QFont &font() const
bool getSvgOverwriteGeneratedFiles()
QString iconDown()
QString iconUp()
bool isCssStyling()
double maxValue()
double minValue()
bool noSystemBackground()
virtual bool numPad()
bool opaquePaintEvent()
bool parseSvgFont()
QString routing()
void setConfirmTimeOut(int ms)
void setCssFile(QString cssFile, bool updateTheme = true)
void setDecimals(int prec)
virtual void setDisabledStateOpacity(double opacity)
void setFont(const QFont &)
virtual void setIQtCDPPointer(IQtCDP *pIQtCDP)
void setIconDown(QString icon)
void setIconUp(QString icon)
void setNoSystemBackground(bool enable)
virtual void setNumPad(bool enable)
void setOpaquePaintEvent(bool enable)
void setParseSvgFont(bool set)
void setRouting(QString routing)
void setStylingType(StylingType type)
void setSuffix(const QString &suffix)
void setSvgFile(const QString &svg)
void setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles)
void setTabToConfirm(bool tab)
void setUpdateOnSlotOnly(bool enable)
StylingType stylingType()
QString svgFile()
bool svgFontDisabled()
bool svgStyling()
bool tabToConfirm()
bool updateOnSlotOnly()
void updateRangeToSupportValue(double value)
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()
void resetToCdp() override
void sendToCdp() override
virtual void setInCommand(bool cmd)
virtual void setMaxValue(double value)
virtual void setMinValue(double value)
virtual void setSmoothPixmap(bool smooth)
virtual void setValue(double value)
virtual void setValue(int value)
virtual void setWidgetFont(const QString &font)
virtual void setWidgetStyle(int style)
virtual void setWidgetTheme(const QString &theme)
virtual void showWidget()

Signals

void pushRoutablesChanged(const QStringList &pushers)
void valueChanged(int)

Protected Functions

QString addUrl(QString path)
void changeEvent(QEvent *e) override
double convertToInputRange(double &value)
void focusOutEvent(QFocusEvent *e) override
QString generatedStyleSheet()
void keyPressEvent(QKeyEvent *event) override
void loadSvg()
QSize minimumSizeHint() const override
void mousePressEvent(QMouseEvent *event) override
bool outsideInputRange(double value) const
void updateOutOfRange(double value)
void updateTextColorFromSvg()
void updateTextFontFromSvg()
void updateTextSizeFromSvg()
  • 4 protected functions inherited from CDPBaseCom
  • 1 protected function inherited from CDPBaseControlVisible

Protected Slots

virtual void emitValueChangedAsInt(double value)
const QString &getCurrentDownIcon(bool isSvg)
const QString &getCurrentUpIcon(bool isSvg)
virtual void handleAcceptedValue(double value)
void initDeprecated()
bool outOfRange() const
virtual const QStringList &pushRoutables() const
virtual void sendStateChanged(const QString &text)
virtual void sendValueToCdp(double value)
virtual void updateCDP(double value)
void updateValueFromCdp()

Additional Inherited Members

  • 2 static public members inherited from CDPBaseCom

Detailed Description

The Spin Box widget is used to display and change numeric values of either signals or parameters from a CDPObject. It can be customized using css, svg files or using the stylesheet.

Note: The widget inherits QDoubleSpinBox and thus all of its properties. These properties are described in the Qt documentation.

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 following tree shows the svg structure that can be used on the CDPBaseSpinBox.

svg
└─── Layer1
      ├─── cdpText                     (text)
      ├─── cdpBorderMarginTopLeft      (transparent rect/path)
      ├─── cdpBorderMarginBottomRight  (transparent rect/path)
      ├─── cdpBackground               (element group)
      ├─── cdpButton                   (element group)
      ├─── cdpButtonUp                 (element group)
      ├─── cdpButtonUpPressed          (element group)
      ├─── cdpButtonUpDisabled         (element group)
      ├─── cdpButtonDown               (element group)
      ├─── cdpButtonDownPressed        (element group)
      ├─── cdpButtonDownDisabled       (element group)
      ├─── cdpIconUp                   (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. 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.
cdpButtonrect or an element group containing a rectThis overrides the cdpButtonUp and cdpButtonDown layer, to make it possible to use the svg file from the button.
cdpButtonUprect or an element group containing a rectThe cdpButtonUp 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.
cdpButtonUpPressedrect or an element group containing a rectThe cdpButtonUpPressed 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.
cdpButtonUpDisabledrect or an element group containing a rectThe cdpButtonUpDisabled 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.
cdpButtonDownrect 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.
cdpButtonDownPressedrect or an element group containing a rectThe cdpButtonDownPressed should contain the graphics to show when the button is pressed. 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.
cdpButtonDownDisabledrect or an element group containing a rectThe cdpButtonDownDisabled 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.
cdpIconUprect 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.
cdpIconUprect 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: Elements that are written with pointy brackets, like < Path >, can be given any name. Avoid cdp prefix as these are special to the parser.

CDPBaseSpinBox 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

typedef CDPBaseSpinBox::StylingSvgMap

enum CDPBaseSpinBox::StylingType

This enum type specifies a styling type:

ConstantValueDescription
CDPBaseSpinBox::NoFile0No custom styling.
CDPBaseSpinBox::CSS1Style by css file.
CDPBaseSpinBox::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 spin 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)

cdpTabToConfirm : bool

This property holds whether or not to make tab confirm edited value similar to enter.

Access functions:

bool tabToConfirm()
void setTabToConfirm(bool tab)

cdpTimeoutMs : int

When the widget is set to a new value and the cdpRouting is set, this property specifies the time to wait before pulling the actual signal/property from the cdp object. If there is no signal at the specified route, default value is 0.0 . Note that this property is ignored if using the widget without adding cdpRouting.

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 enable)

See also resetToCdp and sendToCdp.

cdpVisibleRouting : const QString

This property holds the full path of the signal/parameter to control “visible” property.

Note: Values not equal to 1 are considered false.

cssFile : QString

This property holds the css file to style the widget when styling type is set to css.

Access functions:

QString cssFile()
void setCssFile(QString cssFile, bool updateTheme = true)

See also stylingType.

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 of the spin box.

Access functions:

const QFont &font() const
void setFont(const QFont &)

iconDown : QString

This property holds the icon on the “Down” button.

If stylingType is set to SVG this option overrides the icon parsed from the svg file.

Access functions:

QString iconDown()
void setIconDown(QString icon)

See also stylingType.

iconUp : QString

This property holds the icon on the “Up” button.

If stylingType is set to SVG this option overrides the icon parsed from the svg file.

Access functions:

QString iconUp()
void setIconUp(QString icon)

See also stylingType.

maxValue : double

Access functions:

double maxValue()
virtual void setMaxValue(double value)

maximum : const double

minValue : double

Access functions:

double minValue()
virtual void setMinValue(double value)

minimum : const double

noSystemBackground : bool

Indicates that the widget has no background. Newly exposed areas are never filled with the background.

Access functions:

bool noSystemBackground()
void setNoSystemBackground(bool enable)

numPad : bool

When set to something other than none, the button will open a dialog of type NumPad, KeyPad or PinPad. The latter is normally used in the CDPBaseButtonPopDlg and not in the standard button as we also need to provide a pin code for this to be useful.

Access functions:

virtual bool numPad()
virtual void setNumPad(bool enable)

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)

outOfRange : const bool

postfix : QString

This property holds postfix to display after number (makes suffix deprecated).

Access functions:

void setSuffix(const QString &suffix)

precision : int

This property holds number of decimals to display on value (makes decimals deprecated).

Access functions:

void setDecimals(int prec)

pushRoutables : const QStringList

Notifier signal:

void pushRoutablesChanged(const QStringList &pushers)

stylingType : StylingType

This property holds the styling type to style the widget.

Access functions:

StylingType stylingType()
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 that resources can be overridden by files on disk with identical names. In this widget, the svgFile property can only be edited when the stylingType property is set to SVG.

Access functions:

QString svgFile()
void setSvgFile(const QString &svg)

See also stylingType.

svgFont : bool

Select whether to use local font or font from svg

Access functions:

bool parseSvgFont()
void setParseSvgFont(bool set)

svgOverwriteGeneratedFiles : bool

This property holds whether or not to overwrite previously generated styling files.

Access functions:

bool getSvgOverwriteGeneratedFiles()
void setSvgOverwriteGeneratedFiles(bool svgOverwriteGeneratedFiles)

visible : const bool

This property holds the inherit attribute visible from QWidget.

Member Function Documentation

CDPBaseSpinBox::CDPBaseSpinBox(QWidget *parent = 0)

Default constructs an instance of CDPBaseSpinBox.

[virtual] CDPBaseSpinBox::~CDPBaseSpinBox()

Destroys the instance of CDPBaseSpinBox. The destructor is virtual.

[protected] QString CDPBaseSpinBox::addUrl(QString path)

[protected] void CDPBaseSpinBox::changeEvent(QEvent *e)

[protected] double CDPBaseSpinBox::convertToInputRange(double &value)

[virtual protected slot] void CDPBaseSpinBox::emitValueChangedAsInt(double value)

[protected] void CDPBaseSpinBox::focusOutEvent(QFocusEvent *e)

[protected] QString CDPBaseSpinBox::generatedStyleSheet()

[protected slot] const QString &CDPBaseSpinBox::getCurrentDownIcon(bool isSvg)

[protected slot] const QString &CDPBaseSpinBox::getCurrentUpIcon(bool isSvg)

[virtual protected slot] void CDPBaseSpinBox::handleAcceptedValue(double value)

[virtual slot] void CDPBaseSpinBox::handleVisible(double visible)

[virtual slot] void CDPBaseSpinBox::hideWidget()

[protected slot] void CDPBaseSpinBox::initDeprecated()

bool CDPBaseSpinBox::isCssStyling()

[protected] void CDPBaseSpinBox::keyPressEvent(QKeyEvent *event)

[protected] void CDPBaseSpinBox::loadSvg()

[protected] QSize CDPBaseSpinBox::minimumSizeHint() const

[protected] void CDPBaseSpinBox::mousePressEvent(QMouseEvent *event)

[protected slot] bool CDPBaseSpinBox::outOfRange() const

[protected] bool CDPBaseSpinBox::outsideInputRange(double value) const

[virtual protected slot] const QStringList &CDPBaseSpinBox::pushRoutables() const

[slot] void CDPBaseSpinBox::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 CDPBaseSpinBox::sendStateChanged(const QString &text)

[slot] void CDPBaseSpinBox::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 CDPBaseSpinBox::sendValueToCdp(double value)

[virtual] void CDPBaseSpinBox::setIQtCDPPointer(IQtCDP *pIQtCDP)

[virtual slot] void CDPBaseSpinBox::setInCommand(bool cmd)

[virtual slot] void CDPBaseSpinBox::setSmoothPixmap(bool smooth)

[virtual slot] void CDPBaseSpinBox::setValue(double value)

[virtual slot] void CDPBaseSpinBox::setValue(int value)

[virtual slot] void CDPBaseSpinBox::setWidgetFont(const QString &font)

[virtual slot] void CDPBaseSpinBox::setWidgetStyle(int style)

See also widgetStyle().

[virtual slot] void CDPBaseSpinBox::setWidgetTheme(const QString &theme)

[virtual slot] void CDPBaseSpinBox::showWidget()

bool CDPBaseSpinBox::svgFontDisabled()

bool CDPBaseSpinBox::svgStyling()

[virtual protected slot] void CDPBaseSpinBox::updateCDP(double value)

[protected] void CDPBaseSpinBox::updateOutOfRange(double value)

void CDPBaseSpinBox::updateRangeToSupportValue(double value)

Updates the internal maximum and minimum values to ensure that value is within range.

[protected] void CDPBaseSpinBox::updateTextColorFromSvg()

[protected] void CDPBaseSpinBox::updateTextFontFromSvg()

[protected] void CDPBaseSpinBox::updateTextSizeFromSvg()

[protected slot] void CDPBaseSpinBox::updateValueFromCdp()

[signal] void CDPBaseSpinBox::valueChanged(int)

int CDPBaseSpinBox::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