Pages
API Documentation
On this page

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

List of all members, including inherited members

Public Types

Properties

Public Functions

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
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 0.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 0.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.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.