KNumberModel Class
Creates a model of entries from N to M with rows at a given interval. More...
| Header: | #include <KNumberModel> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS ItemModels)target_link_libraries(mytarget PRIVATE KF6::ItemModels) |
| Inherits: | QAbstractListModel |
Public Types
| enum | Roles { DisplayRole, ValueRole } |
Properties
- formattingOptions : QLocale::NumberOptions
- maximumValue : qreal
- minimumValue : qreal
- stepSize : qreal
Public Functions
| KNumberModel(QObject *parent = nullptr) | |
| QLocale::NumberOptions | formattingOptions() const |
| qreal | maximumValue() const |
| qreal | minimumValue() const |
| void | setFormattingOptions(QLocale::NumberOptions options) |
| void | setMaximumValue(qreal maximumValue) |
| void | setMinimumValue(qreal minimumValue) |
| void | setStepSize(qreal stepSize) |
| qreal | stepSize() const |
| qreal | value(const QModelIndex &index) const |
Signals
| void | formattingOptionsChanged() |
| void | maximumValueChanged() |
| void | minimumValueChanged() |
| void | stepSizeChanged() |
Detailed Description
The model contains two roles:
- display - the number represented as a string
- value - the actual value as a number
Member Type Documentation
enum KNumberModel::Roles
| Constant | Value |
|---|---|
KNumberModel::DisplayRole | Qt::DisplayRole |
KNumberModel::ValueRole | Qt::UserRole |
Property Documentation
formattingOptions : QLocale::NumberOptions
Defines the string representation of the number, e.g. "1,000" or "1000".
Default is QLocale::Default.
Access functions:
| QLocale::NumberOptions | formattingOptions() const |
| void | setFormattingOptions(QLocale::NumberOptions options) |
Notifier signal:
| void | formattingOptionsChanged() |
maximumValue : qreal
The maximum value for the model
The default value is 1.0.
Note: If maximumValue is a multiple of stepSize added to minimumValue it will be included. Otherwise it will not be reached. E.g. in a model with a minimumValue of 0.0, a maximumValue of 1.0 and a stepSize of 0.3, the final row will be 0.9.
Access functions:
| qreal | maximumValue() const |
| void | setMaximumValue(qreal maximumValue) |
Notifier signal:
| void | maximumValueChanged() |
minimumValue : qreal
The minimum value for the model
The default value is 1.0.
Access functions:
| qreal | minimumValue() const |
| void | setMinimumValue(qreal minimumValue) |
Notifier signal:
| void | minimumValueChanged() |
stepSize : qreal
Step between listed entries
The default value is 1.0.
Access functions:
| qreal | stepSize() const |
| void | setStepSize(qreal stepSize) |
Notifier signal:
| void | stepSizeChanged() |
Member Function Documentation
[explicit] KNumberModel::KNumberModel(QObject *parent = nullptr)
qreal KNumberModel::value(const QModelIndex &index) const
Returns the value represented at the given index.