Skip to content

Class QfValueMapModel

ClassList > QfValueMapModel

More...

  • #include <qfvaluemapmodel.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
QfValueMapModel (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 QfValueMapModel::ValueMapRoles {
    KeyRole = Qt::UserRole + 1,
    ValueRole
};


Public Properties Documentation

property valueMap

QVariant QfValueMapModel::valueMap;

A list of QVariantMap, wrapped in a QVariant.

Like this:

[{'CH': 'Switzerland'}, {'DE': 'Germany'}, {'FR': 'France'}]


Public Signals Documentation

signal mapChanged

void QfValueMapModel::mapChanged;

Emitted when the map changes.


Public Functions Documentation

function QfValueMapModel

explicit QfValueMapModel::QfValueMapModel (
    QObject * parent=nullptr
) 

Create a new value map model


function keyForValue

Q_INVOKABLE QVariant QfValueMapModel::keyForValue (
    const QString & value
) const

Returns the key for a value or an invalid QVariant if not found.


function keyToIndex

Q_INVOKABLE int QfValueMapModel::keyToIndex (
    const QVariant & key
) const

Returns the row (index) of a key or -1 if not found.


function map

QVariant QfValueMapModel::map () const

The map, see the property description


function setMap

void QfValueMapModel::setMap (
    const QVariant & map
) 

The map, see the property description


Protected Functions Documentation

function filterAcceptsRow

bool QfValueMapModel::filterAcceptsRow (
    int sourceRow,
    const QModelIndex & sourceParent
) override const


The documentation for this class was generated from the following file src/gui/qfvaluemapmodel.h