Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxComboBox Class Reference

Enhanced version of Qt combo box class. More...

#include <QtxComboBox.h>

Inheritance diagram for QtxComboBox:
Inheritance graph

Classes

class  ClearEvent
 Custom event, used to process 'cleared' state of the combo box in editable mode. More...
 
class  Model
 Internal view model, used to process 'cleared' state of the combo box. More...
 

Signals

void activatedId (QVariant)
 Emitted when item with identificator ident is activated. More...
 
void activatedId (int)
 Emitted when item with integer identificator ident is activated. More...
 
void activatedId (QString)
 Emitted when item with string identificator ident is activated. More...
 

Public Member Functions

 QtxComboBox (QWidget *=0)
 Constructor. More...
 
virtual ~QtxComboBox ()
 Destructor. More...
 
bool isCleared () const
 Check if combo box is in "cleared" state. More...
 
void setCleared (const bool)
 Set "cleared" state. More...
 
QVariant currentId () const
 Get current item's identifier. More...
 
void setCurrentId (const QVariant &)
 Set current item by identifier. More...
 
QVariant id (const int) const
 Get item's identifier by index. More...
 
int index (const QVariant &) const
 Get item index by identifier. More...
 
bool hasId (const int) const
 Check if item has assigned identifier. More...
 
void setId (const int, const QVariant &)
 Assign identifier to specified item. More...
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
 Customize paint event. More...
 
virtual void childEvent (QChildEvent *)
 Customize child addition/removal event. More...
 
virtual void customEvent (QEvent *)
 Process custom events. More...
 

Private Types

enum  { IdRole = Qt::UserRole + 10 }
 

Private Slots

void onCurrentChanged (int)
 Called when current item is changed (by user or programmatically). More...
 

Private Member Functions

void resetClear ()
 Reset "cleared" state and update combo box. More...
 

Private Attributes

bool myCleared
 "cleared" state More...
 

Detailed Description

In addition to the QComboBox class, QtxComboBox supports adding/removing the items with the associated unique identifiers. It also provides a way to set "cleared" state to the combo box - when no item is selected.

Member Enumeration Documentation

anonymous enum
private
Enumerator
IdRole 

Constructor & Destructor Documentation

QtxComboBox::QtxComboBox ( QWidget parent = 0)
Parameters
parentparent widget

References onCurrentChanged().

QtxComboBox::~QtxComboBox ( )
virtual

Member Function Documentation

void QtxComboBox::activatedId ( QVariant  ident)
signal
Parameters
identitem's identifier
void QtxComboBox::activatedId ( int  ident)
signal
Parameters
identitem's identifier
void QtxComboBox::activatedId ( QString  ident)
signal
Parameters
identitem's identifier
void QtxComboBox::childEvent ( QChildEvent *  e)
protectedvirtual
Parameters
echild event
QVariant QtxComboBox::currentId ( ) const
Returns
current item's identifier

References id().

void QtxComboBox::customEvent ( QEvent e)
protectedvirtual
Parameters
ecustom event

References CLEAR_EVENT, and myCleared.

bool QtxComboBox::hasId ( const int  idx) const
Parameters
idxitem's index
Returns
true if item with given index has identifier of false otherwise

References IdRole.

QVariant QtxComboBox::id ( const int  idx) const
Parameters
idxitem's index
Returns
item's identifier or invalid QVariant if index is out of range or identifier is not assigned to item

References IdRole.

int QtxComboBox::index ( const QVariant &  ident) const
Parameters
identitem's identifier
Returns
item's index or -1 if ident is invalid of if item is not found

References IdRole.

bool QtxComboBox::isCleared ( ) const
Returns
true if combo box is in "cleared" state or false otherwise

References myCleared.

void QtxComboBox::onCurrentChanged ( int  idx)
privateslot
Parameters
idxindex of item being set current

References activatedId(), id(), and resetClear().

void QtxComboBox::paintEvent ( QPaintEvent *  e)
protectedvirtual
Parameters
epaint event

References myCleared, and QtxComboBox::Model::setCleared().

void QtxComboBox::resetClear ( )
private

References myCleared.

void QtxComboBox::setCleared ( const bool  isClear)
Parameters
isClearnew "cleared" state

References myCleared.

void QtxComboBox::setCurrentId ( const QVariant &  ident)
Parameters
identitem's identifier

References index().

void QtxComboBox::setId ( const int  idx,
const QVariant &  ident 
)
Parameters
idxitem's index
identitem's identifier

References IdRole.

Member Data Documentation

bool QtxComboBox::myCleared
private

The documentation for this class was generated from the following files: