CDPBaseLineEdit Class
The Line Edit is used for editing text or numeric values. Text input is done by keyboard or touch screen pad. More...
Header: | #include <CDPBaseWidgets/CDPBaseLineEdit.h> |
Inherits: | CDPBaseControlVisible, StateChanger, CDPBasePadLauncher, CDPBaseCom, |
Public Types
enum | GlobalDialog { None, NumPad, KeyPad, PinPad } |
enum | NumForm { Normal, Scientific, MixedMode } |
typedef | StylingSvgMap |
enum | StylingType { NoFile, CSS, SVG } |
Properties
|
|
Public Functions
CDPBaseLineEdit(QWidget *parent = 0) | |
virtual | ~CDPBaseLineEdit() |
void | Connect(std::string strRemoteObjectName) override |
QString | cdpStyle() |
int | cdpTimeoutMs() |
bool | convertStringToDouble() |
QString | cssFile() |
virtual double | disabledStateOpacity() const |
int | getFocusTimeOut() |
StylingType | getStylingType() |
bool | isCssStyling() |
bool | isSvgStyling() |
NumForm | numFormat() |
QString | postfix() |
int | precision() |
bool | promptForChanges() |
virtual const QStringList & | pushRoutables() const |
QString | routing() |
void | setCdpStyle(QString routing) |
void | setCdpTimeoutMs(int ms) |
void | setConvertStringToDouble(bool enabled) |
void | setCssFile(QString cssFile) |
virtual void | setDisabledStateOpacity(double opacity) |
void | setFocusTimeOut(int ms) |
void | setIQtCDPPointer(IQtCDP *pIQtCDP) override |
void | setNumFormat(NumForm format) |
void | setPostfix(const QString &qstrPostfix) |
void | setPrecision(int value) |
void | setPromptForChanges(bool) |
void | setRouting(QString routing) |
void | setStylingType(StylingType type) |
void | setSvgFile(const QString &svg) |
void | setTabToConfirm(bool tab) |
void | setUpdateOnSlotOnly(bool update) |
QString | svgFile() |
bool | tabToConfirm() |
bool | updateOnSlotOnly() |
double | value(bool *bOk = 0) |
bool | valueIsWithinRange(double value) |
Reimplemented Public Functions
virtual QString | keyPadDisplayText() override |
virtual QLineEdit::EchoMode | keyPadEchoMode() override |
virtual double | keyPadMaxValue() |
virtual double | keyPadMinValue() |
- 4 public functions inherited from CDPBaseControlVisible
- 3 public functions inherited from StateChanger
- 26 public functions inherited from CDPBasePadLauncher
- 17 public functions inherited from CDPBaseCom
Public Slots
virtual QColor | fontColor() |
virtual void | handleVisible(double visible) |
virtual void | hideWidget() |
virtual GlobalDialog | padType() |
void | resetToCdp() override |
void | sendToCdp() override |
virtual void | setFontColor(QColor color) |
virtual void | setInCommand(bool cmd) |
virtual void | setMaxValue(double value) |
virtual void | setMinValue(double value) |
virtual void | setPadType(GlobalDialog dialog) |
virtual void | setSmoothPixmap(bool smooth) |
virtual void | setTextAndUpdateCdp(QString str) |
virtual void | setValue(double value) |
virtual void | setValue(int value) |
virtual bool | setValue(QString value, bool bScale) |
virtual void | setValueAndUpdateCdp(double value) |
virtual void | setValueAndUpdateCdp(int value) |
virtual void | setWidgetFont(const QString &font) |
virtual void | setWidgetStyle(int style) |
virtual void | setWidgetStyle(double style) |
virtual void | setWidgetTheme(const QString &theme) |
virtual void | showPad() |
virtual void | showWidget() |
virtual int | widgetStyle() |
Signals
void | pushRoutablesChanged(const QStringList &pushers) |
void | signalAcceptedValue(int) |
void | signalAcceptedValue(double) |
void | signalAcceptedValue(QString) |
Protected Functions
QString | addUrl(QString path) |
void | changeEvent(QEvent *e) override |
virtual void | focusInEvent(QFocusEvent *) |
virtual void | focusOutEvent(QFocusEvent *) |
QString | generatedStyleSheet() |
virtual void | keyPressEvent(QKeyEvent *) |
void | loadSvg() |
virtual void | mouseReleaseEvent(QMouseEvent *) |
void | processSvgFile(QString svg) |
void | updateTextColorFromSvg() |
- 1 protected function inherited from CDPBaseControlVisible
- 1 protected function inherited from CDPBasePadLauncher
- 4 protected functions inherited from CDPBaseCom
Protected Slots
virtual void | acceptedValue(double value) |
virtual void | acceptedValue(QString value) |
void | checkTextAndUpdateCdp() |
void | clearFocusAndUpdateTextFromCdp() |
virtual void | clearInputFocus() |
void | initDefaultStyle() |
void | initDeprecated() |
void | processCursorPosChanged(int old = 0, int n = 0) |
virtual void | sendStateChanged(const QString &text) |
virtual void | sendValueToCdp() |
void | startFocusTimer() |
void | updateTextFromCdp() |
void | validateDisplayString(QString dummy = "") |
Additional Inherited Members
- 2 static public members inherited from CDPBaseCom
Detailed Description
The Line Edit is used for editing text or numeric values. Text input is done by keyboard or touch screen pad.
The widget can be configured to send and receive text or numeric values to and from CDP objects/properties by configuring the cdpRouting property. All properties related to communication are prefixed with cdp.
There are lots of properties for changing the widget look and feel. For instance, texts can be added after the editable value by configuring the postfix property. To add text in front of the value, we need to group the Line Edit with a Label in front.
To support touch screens, or when no keyboard is present, the properties prefixed with pad can be used to make the widget launch a numeric pad, a text pad or a pad for typing in passwords.
Styling of the Line Edit, text color, font and background, is usually done by the selected theme. To check this, have a look at the stylingType property. When the default type, SVG is selected, the file showing in svgFile is responsible for setting fonts and colors. You can override this using the properties named fontColor and font. The override will be kept even if theme is changed.
To override the background, you will have to create a new SVG file or select a different styling type. Setting the stylingType property to CSS will enable the cssFile property and allow you to specify a CSS file to style the widget. It is also possible to add CSS code directly in the styleSheet property. To make these changes stick we need to set stylingType to NoFile.
There is also a final styling option, palette, that can be used when stylingType is set to NoFile and none of the other styling options are present (does not show in bold).
Some of the most important features of the Line Edit is summarized in the following table:
Name | Type | Description |
---|---|---|
cdpPromptForChanges | bool | Enable or disable message box to confirm new value/text to send to routed cdp object/property. |
cdpRouting | string | Routing to a CDP object/property that we want to display and edit. |
cdpStyleRouting | string | Routing to a CDP object/property that controls what style element in the SVG to show on the LineEdit. This can be used to make the Line Edit show differently based on external events. We could for instance make the background red if an alarm is set. |
cdpScaling | double | Display scaling on data to/from routed CDP object/property. Input values to the CDPBaseLineEdit will be multiplied with this value, output values will be divided. |
numFormat | NumForm | Specify display format; "Normal", "Scientific" or "Mixed". |
padTitle | string | The title of the pad when padType is not set to None. |
padType | GlobalDialog | The title of the pad when padType is not set to "None". |
postfix | string | Text to display after actual value/text. |
precision | int | Sets the number of decimals to show when displaying fractured numbers or number of decimal notations before switching to scientific display in “MixedMode” |
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).
Note: CDPBaseLineEdit 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.
The raster images are only generated the first time a SVG file is loaded. Hence, theme designers might need to delete the temporary files if making changes to a file that has already been loaded.
Main element structure
The CDPBaseLineEdit can use the standard svg structure of the CDPBaseSpinBox. The following svg structure is supported.
svg └─── Layer1 ├─── cdpText (text) ├─── cdpBorderMarginTopLeft (transparent rect/path) ├─── cdpBorderMarginBottomRight (transparent rect/path) └─── cdpBackground (element group)
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 only use the color from this layer. |
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. |
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.
Member Type Documentation
enum CDPBaseLineEdit::GlobalDialog
This enum type specifies a dialog type:
Constant | Value | Description |
---|---|---|
CDPBaseLineEdit::None | CDPBasePadLauncher::None | Do not use a global dialog. |
CDPBaseLineEdit::NumPad | CDPBasePadLauncher::NumPad | A numeric key pad. |
CDPBaseLineEdit::KeyPad | CDPBasePadLauncher::KeyPad | A key pad with for numbers and letters. |
CDPBaseLineEdit::PinPad | CDPBasePadLauncher::PinPad | A num pad for typing passwords. |
enum CDPBaseLineEdit::NumForm
This enum type specifies how to format numbers:
Constant | Value | Description |
---|---|---|
CDPBaseLineEdit::Normal | 1 | Format as [-]9.9 |
CDPBaseLineEdit::Scientific | 2 | Format as [-]9.9e[+|-]999 |
CDPBaseLineEdit::MixedMode | 3 | Use "Normal" or "Scientific" format, whichever is the most concise. |
typedef CDPBaseLineEdit::StylingSvgMap
enum CDPBaseLineEdit::StylingType
This enum type specifies a styling type:
Property Documentation
cdpOfflineValue : const QString
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.
cdpPromptForChanges : bool
This property holds whether to show a message box to accept changes.
Note: The prompt dialog will only show when configured for cdp communication and only in a running application.
Access functions:
bool | promptForChanges() |
void | setPromptForChanges(bool) |
See also cdpRouting.
cdpRouting : QString
This property holds the routing to the CDP object to connect and control.
The routing is bi-directional. This means that if two line edits 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) |
cdpScaling : const double
This property holds a value with which the decimal (if present) value is multiplied/divided.
Input-values to the CDPBaseLineEdit will be multiplied with this value, output-values will be divided. This works with both signals and properties.
cdpStringToDouble : bool
This property holds whether or not we should try to convert received strings to double.
Access functions:
bool | convertStringToDouble() |
void | setConvertStringToDouble(bool enabled) |
cdpStyleRouting : QString
This property holds the routing of the CDP object that is used to change the widget svg style.
Access functions:
QString | cdpStyle() |
void | setCdpStyle(QString routing) |
cdpTabToConfirm : bool
This property holds whether to use “Tab” to confirm text input.
Access functions:
bool | tabToConfirm() |
void | setTabToConfirm(bool tab) |
cdpTimeoutMs : int
This property holds the time to wait before confirming a newly inserted value.
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 | cdpTimeoutMs() |
void | setCdpTimeoutMs(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.
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-qlineedit
Access functions:
QString | cssFile() |
void | setCssFile(QString cssFile) |
See also svgFile.
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) |
focusTimeOutMs : int
This property holds the time after which the lineEdit looses focus after being edited.
This time delay makes sure the widget shows updated values from the routed cdp object.
Access functions:
int | getFocusTimeOut() |
void | setFocusTimeOut(int ms) |
fontColor : QColor
This property holds the font color.
Note: If this is set, this overrides the text color from svg file and the entire code received from CSS file.
Note: When combined with max and min, recieving an out-of-range input will reset this color.
Access functions:
virtual QColor | fontColor() |
virtual void | setFontColor(QColor color) |
maximum : const double
This property holds the maximum value to accept from user.
When the user attempts to add a value above this maximum, the line edit text will get colored in red and a focus out event will make the text go back to the previous value.
Note: Receiving cdp values that are out of range will extend the min/max limits so that we always show what is in the control system. Further, the min/max values will also limit the num pad (when enabled). Setting min and max with identical value will disable the functionality.
Access functions:
virtual double | keyPadMaxValue() |
See also minimum.
minimum : const double
This property holds the minimum value to accept from user.
When the user attempts to add a value below this minimum, the line edit text will get colored in red and a focus out event will make the text go back to the previous value.
Note: Receiving cdp values that are out of range will extend the min/max limits so that we always show what is in the control system. Further, the min/max values will also limit the num pad (when enabled). Setting min and max with identical value will disable the functionality.
Access functions:
virtual double | keyPadMinValue() |
See also maximum.
numFormat : NumForm
This property holds the format in which numbers are displayed.
Access functions:
NumForm | numFormat() |
void | setNumFormat(NumForm format) |
See also precision.
padInfoText1 : const QString
This property holds the first information text of the input pad.
The info text will only show when the global num pad class in the main window, CDPBaseMainWindow::numPadName, has been configured with a class that implements the pad info elements. An example of such is the class named CDPBaseNumPadOptInfo. Also, have a look at the CDPBaseNumPad details for more information regarding the info texts.
Remember to set padType to num pad when using this property.
See also padType, padTitle, and padInfoText2.
padInfoText2 : const QString
This property holds the second info text of the input pad. See padInfoText1 for more details.
See also padType, padTitle, and padInfoText1.
padTitle : const QString
This property holds the title of the input-pad.
See also padType, padInfoText1, and padInfoText2.
padType : GlobalDialog
This property holds which input pad is used for inserting a value manually.
Access functions:
virtual GlobalDialog | padType() |
virtual void | setPadType(GlobalDialog dialog) |
See also padTitle, padInfoText1, and padInfoText2.
postfix : QString
This property holds the string that is appended to the displayed value.
Access functions:
QString | postfix() |
void | setPostfix(const QString &qstrPostfix) |
precision : int
This property holds the value of decimal places for numbers.
Sets the number of decimals to show when displaying fractured numbers or number of decimal notations before switching to scientific display in “MixedMode”
Access functions:
int | precision() |
void | setPrecision(int value) |
See also numFormat.
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.
To customize in QtDesigner, set this property to "NoFile".
Access functions:
StylingType | getStylingType() |
void | setStylingType(StylingType type) |
See also svgFile, cssFile, and widgetStyle.
svgFile : QString
This property holds the svg file to use for customization.
Access functions:
QString | svgFile() |
void | setSvgFile(const QString &svg) |
See also cssFile.
visible : const bool
This property holds whether to show the QWidget or not.
See also cdpVisibleRouting.
widgetStyle : int
This property holds which style from an svg file is used.
Note: This will only have effect if the svg file specified by svgFile provides styles, and stylingType is set to "SVG".
Access functions:
virtual int | widgetStyle() |
virtual void | setWidgetStyle(int style) |
virtual void | setWidgetStyle(double style) |
See also stylingType, svgFile, and cssFile.
Member Function Documentation
CDPBaseLineEdit::CDPBaseLineEdit(QWidget *parent = 0)
Default constructs an instance of CDPBaseLineEdit.
[virtual]
CDPBaseLineEdit::~CDPBaseLineEdit()
Destroys the instance of CDPBaseLineEdit. The destructor is virtual.
void CDPBaseLineEdit::Connect(std::string strRemoteObjectName)
[virtual protected slot]
void CDPBaseLineEdit::acceptedValue(double value)
[virtual protected slot]
void CDPBaseLineEdit::acceptedValue(QString value)
[protected]
QString CDPBaseLineEdit::addUrl(QString path)
[protected]
void CDPBaseLineEdit::changeEvent(QEvent *e)
[protected slot]
void CDPBaseLineEdit::checkTextAndUpdateCdp()
[protected slot]
void CDPBaseLineEdit::clearFocusAndUpdateTextFromCdp()
[virtual protected slot]
void CDPBaseLineEdit::clearInputFocus()
[virtual protected]
void CDPBaseLineEdit::focusInEvent(QFocusEvent *)
[virtual protected]
void CDPBaseLineEdit::focusOutEvent(QFocusEvent *)
[protected]
QString CDPBaseLineEdit::generatedStyleSheet()
[virtual slot]
void CDPBaseLineEdit::handleVisible(double visible)
[virtual slot]
void CDPBaseLineEdit::hideWidget()
[protected slot]
void CDPBaseLineEdit::initDefaultStyle()
[protected slot]
void CDPBaseLineEdit::initDeprecated()
bool CDPBaseLineEdit::isCssStyling()
bool CDPBaseLineEdit::isSvgStyling()
[override virtual]
QString CDPBaseLineEdit::keyPadDisplayText()
[override virtual]
QLineEdit::EchoMode CDPBaseLineEdit::keyPadEchoMode()
[virtual protected]
void CDPBaseLineEdit::keyPressEvent(QKeyEvent *)
[protected]
void CDPBaseLineEdit::loadSvg()
[virtual protected]
void CDPBaseLineEdit::mouseReleaseEvent(QMouseEvent *)
[protected slot]
void CDPBaseLineEdit::processCursorPosChanged(int old = 0, int n = 0)
[protected]
void CDPBaseLineEdit::processSvgFile(QString svg)
[slot]
void CDPBaseLineEdit::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 CDPBaseLineEdit::sendStateChanged(const QString &text)
[slot]
void CDPBaseLineEdit::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 CDPBaseLineEdit::sendValueToCdp()
void CDPBaseLineEdit::setIQtCDPPointer(IQtCDP *pIQtCDP)
[virtual slot]
void CDPBaseLineEdit::setInCommand(bool cmd)
[virtual slot]
void CDPBaseLineEdit::setMaxValue(double value)
[virtual slot]
void CDPBaseLineEdit::setMinValue(double value)
[virtual slot]
void CDPBaseLineEdit::setSmoothPixmap(bool smooth)
[virtual slot]
void CDPBaseLineEdit::setTextAndUpdateCdp(QString str)
[virtual slot]
void CDPBaseLineEdit::setValue(double value)
See also value().
[virtual slot]
void CDPBaseLineEdit::setValue(int value)
[virtual slot]
bool CDPBaseLineEdit::setValue(QString value, bool bScale)
[virtual slot]
void CDPBaseLineEdit::setValueAndUpdateCdp(double value)
[virtual slot]
void CDPBaseLineEdit::setValueAndUpdateCdp(int value)
[virtual slot]
void CDPBaseLineEdit::setWidgetFont(const QString &font)
[virtual slot]
void CDPBaseLineEdit::setWidgetTheme(const QString &theme)
[virtual slot]
void CDPBaseLineEdit::showPad()
Slot that will launch any configured pad and show the value of the cdp object routed in cdpRouting. This enables the widget to be used as a generic pad launcher. Connect it to any widget and hide the line edit by setting stylingType to NoFile and the following styleSheet
QLineEdit{ color:transparent; background: transparent; border: 0; }
See also padType, padTitle, and cdpRouting.
[virtual slot]
void CDPBaseLineEdit::showWidget()
[signal]
void CDPBaseLineEdit::signalAcceptedValue(int)
Note: Signal signalAcceptedValue is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(cDPBaseLineEdit, static_cast<void(CDPBaseLineEdit::*)(int)>(&CDPBaseLineEdit::signalAcceptedValue), [=](int ){ /* ... */ });
[signal]
void CDPBaseLineEdit::signalAcceptedValue(double)
Note: Signal signalAcceptedValue is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(cDPBaseLineEdit, static_cast<void(CDPBaseLineEdit::*)(double)>(&CDPBaseLineEdit::signalAcceptedValue), [=](double ){ /* ... */ });
[signal]
void CDPBaseLineEdit::signalAcceptedValue(QString)
Note: Signal signalAcceptedValue is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(cDPBaseLineEdit, static_cast<void(CDPBaseLineEdit::*)(QString)>(&CDPBaseLineEdit::signalAcceptedValue), [=](QString ){ /* ... */ });
[protected slot]
void CDPBaseLineEdit::startFocusTimer()
[protected]
void CDPBaseLineEdit::updateTextColorFromSvg()
[protected slot]
void CDPBaseLineEdit::updateTextFromCdp()
[protected slot]
void CDPBaseLineEdit::validateDisplayString(QString dummy = "")
double CDPBaseLineEdit::value(bool *bOk = 0)
See also setValue().
bool CDPBaseLineEdit::valueIsWithinRange(double value)
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.