Class ValueMapModel
#include <valuemapmodel.h>
Inherits the following classes: QSortFilterProxyModel
Public Types
| Type | Name |
|---|---|
| enum | ValueMapRoles The roles provided by this model. |
Public Properties
| Type | Name |
|---|---|
| property QVariant | valueMap |
Public Signals
| Type | Name |
|---|---|
| signal void | mapChanged |
Public Functions
| Type | Name |
|---|---|
| ValueMapModel (QObject * parent=nullptr) |
|
| Q_INVOKABLE QVariant | keyForValue (const QString & value) const |
| Q_INVOKABLE int | keyToIndex (const QVariant & key) const |
| QVariant | map () const |
| void | setMap (const QVariant & map) |
Protected Functions
| Type | Name |
|---|---|
| bool | filterAcceptsRow (int sourceRow, const QModelIndex & sourceParent) override const |
Detailed Description
A model that manages the key/value pairs for a ValueMap widget.
Public Types Documentation
enum ValueMapRoles
The roles provided by this model.
enum ValueMapModel::ValueMapRoles {
KeyRole = Qt::UserRole + 1,
ValueRole
};
Public Properties Documentation
property valueMap
QVariant ValueMapModel::valueMap;
A list of QVariantMap, wrapped in a QVariant.
Like this:
[{'CH': 'Switzerland'}, {'DE': 'Germany'}, {'FR': 'France'}]
Public Signals Documentation
signal mapChanged
void ValueMapModel::mapChanged;
Emitted when the map changes.
Public Functions Documentation
function ValueMapModel
explicit ValueMapModel::ValueMapModel (
QObject * parent=nullptr
)
Create a new value map model
function keyForValue
Q_INVOKABLE QVariant ValueMapModel::keyForValue (
const QString & value
) const
Returns the key for a value or an invalid QVariant if not found.
function keyToIndex
Q_INVOKABLE int ValueMapModel::keyToIndex (
const QVariant & key
) const
Returns the row (index) of a key or -1 if not found.
function map
QVariant ValueMapModel::map () const
The map, see the property description
function setMap
void ValueMapModel::setMap (
const QVariant & map
)
The map, see the property description
Protected Functions Documentation
function filterAcceptsRow
bool ValueMapModel::filterAcceptsRow (
int sourceRow,
const QModelIndex & sourceParent
) override const
The documentation for this class was generated from the following file src/core/valuemapmodel.h