QwpComboBox Class Reference

The QwpComboBox class is a simple extension to QComboBox. It provides a read-write currentKey property. More...

#include <qwpcombobox.h>

List of all members.

Public Slots

void setCurrentKey (const QVariant &key)

Public Member Functions

 QwpComboBox (QWidget *parent=0)
QVariant itemKey (int index) const
QVariant currentKey () const

Properties

QVariant currentKey


Detailed Description

The QwpComboBox class is a simple extension to QComboBox. It provides a read-write currentKey property.

The reason that this class exists is to allow comboboxes to be used with the SettingsController::bind() feature in a way that is useful.

For example, you may have a dynamic combox-box full of SQL drivers, where the "key" is Qt's SQL driver name (e.g. "QPSQL") and the text is a user-friendly version of the driver name (e.g. "PostgreSQL"). In this case, using QComboBox's only read-write "current" property for persistent storage would not only be meaningless by value, but whenever the set of available drivers changes the value could point to different driver items. Thus the currentKey property is used for storage and synchronisation. (Note: The currentText couldn't be used either, as it should be language dependant and may be changed or other reasons, whereas the stored value shouldn't).

The currentKey uses the Qt::UserRole. Thus, the key and text pair can set using one of the following lines:

 addItem( text, key );
 insertItem( text, key );


Constructor & Destructor Documentation

QwpComboBox::QwpComboBox ( QWidget *  parent = 0  ) 

Constructs a combobox with the given parent.


Member Function Documentation

QVariant QwpComboBox::itemKey ( int  index  )  const

Consistency method. Equalivant to itemData(index, Qt::UserRole).

QVariant QwpComboBox::currentKey (  )  const

void QwpComboBox::setCurrentKey ( const QVariant &  key  )  [slot]

Method required for the writing the currentKey property.


Property Documentation

QVariant QwpComboBox::currentKey [read, write]

Method required for the reading the currentKey property.


The documentation for this class was generated from the following files:
Generated on Mon Jul 30 09:46:53 2007 for Digest by  doxygen 1.5.2