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

CDP Studio

Software development tool for distributed control systems

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • 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 <CDPBaseWidgets/CDPBaseSpinBox.h>
Inherits: StateChanger, CDPBaseCom, CDPBaseControlVisible,
  • List of all members, including inherited members

Public Types

typedef StylingSvgMap
enum StylingType { NoFile, CSS, SVG }

Properties

  • cdpRouting : QString
  • cdpTabToConfirm : bool
  • cdpTimeoutMs : int
  • cdpUpdateOnSlotOnly : bool
  • cdpVisibleRouting : const QString
  • cssFile : QString
  • font : QFont
  • iconDown : QString
  • iconUp : QString
  • noSystemBackground : bool
  • numPad : bool
  • opaquePaintEvent : 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()
const QFont &font() const
bool getSvgOverwriteGeneratedFiles()
QString iconDown()
QString iconUp()
bool isCssStyling()
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)
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
  • 14 public functions inherited from CDPBaseCom
  • 4 public functions inherited from CDPBaseControlVisible

Public Slots

virtual void handleVisible(double visible)
virtual void hideWidget()
virtual void sendToCdp()
virtual void setInCommand(bool cmd)
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)
virtual void focusOutEvent(QFocusEvent *e)
QString generatedStyleSheet()
virtual void keyPressEvent(QKeyEvent *event)
void loadSvg()
QSize minimumSizeHint() const override
void mousePressEvent(QMouseEvent *event) override
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()
virtual const QStringList &pushRoutables() const
virtual void sendStateChanged(const QString &text)
virtual void sendValueToCdp(double value)
virtual void updateCDP(double value)
void updateValueFromCdp()

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

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

Set to only use a slot (sendToCdp()) to send the value to routed cdp object. This makes the widget not send value to cdp upon qt events like editingFinished and enterPressed.

Access functions:

bool updateOnSlotOnly()
void setUpdateOnSlotOnly(bool enable)

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.

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.

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)

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)

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

[virtual 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()

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

[protected] void CDPBaseSpinBox::loadSvg()

[protected] QSize CDPBaseSpinBox::minimumSizeHint() const

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

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

[virtual protected slot] void CDPBaseSpinBox::sendStateChanged(const QString &text)

[virtual slot] void CDPBaseSpinBox::sendToCdp()

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

void CDPBaseSpinBox::updateRangeToSupportValue(double value)

[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

Follow CDP

    © Copyright 2021 CDP Technologies. Privacy and cookie policy.

    Return to top