Version: 9.15.0
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

Enhanced version of Qt combo box class.

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

anonymous enum
private
Enumerator
IdRole 

Constructor & Destructor Documentation

◆ QtxComboBox()

QtxComboBox::QtxComboBox ( QWidget parent = 0)

Constructor.

Parameters
parentparent widget

References onCurrentChanged().

◆ ~QtxComboBox()

QtxComboBox::~QtxComboBox ( )
virtual

Destructor.

Member Function Documentation

◆ activatedId [1/3]

void QtxComboBox::activatedId ( int  ident)
signal

Emitted when item with integer identificator ident is activated.

Parameters
identitem's identifier

◆ activatedId [2/3]

void QtxComboBox::activatedId ( QString  ident)
signal

Emitted when item with string identificator ident is activated.

Parameters
identitem's identifier

◆ activatedId [3/3]

void QtxComboBox::activatedId ( QVariant  ident)
signal

Emitted when item with identificator ident is activated.

Parameters
identitem's identifier

◆ childEvent()

void QtxComboBox::childEvent ( QChildEvent *  e)
protectedvirtual

Customize child addition/removal event.

Parameters
echild event

◆ currentId()

QVariant QtxComboBox::currentId ( ) const

Get current item's identifier.

Returns
current item's identifier

References id().

◆ customEvent()

void QtxComboBox::customEvent ( QEvent e)
protectedvirtual

Process custom events.

Parameters
ecustom event

References CLEAR_EVENT, and myCleared.

◆ hasId()

bool QtxComboBox::hasId ( const int  idx) const

Check if item has assigned identifier.

Parameters
idxitem's index
Returns
true if item with given index has identifier of false otherwise

References IdRole.

◆ id()

QVariant QtxComboBox::id ( const int  idx) const

Get item's identifier by index.

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.

◆ index()

int QtxComboBox::index ( const QVariant &  ident) const

Get item index by identifier.

Parameters
identitem's identifier
Returns
item's index or -1 if ident is invalid of if item is not found

References IdRole.

◆ isCleared()

bool QtxComboBox::isCleared ( ) const

Check if combo box is in "cleared" state.

Returns
true if combo box is in "cleared" state or false otherwise

References myCleared.

◆ onCurrentChanged

void QtxComboBox::onCurrentChanged ( int  idx)
privateslot

Called when current item is changed (by user or programmatically).

Parameters
idxindex of item being set current

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

◆ paintEvent()

void QtxComboBox::paintEvent ( QPaintEvent *  e)
protectedvirtual

Customize paint event.

Parameters
epaint event

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

◆ resetClear()

void QtxComboBox::resetClear ( )
private

Reset "cleared" state and update combo box.

References myCleared.

◆ setCleared()

void QtxComboBox::setCleared ( const bool  isClear)

Set "cleared" state.

Parameters
isClearnew "cleared" state

References myCleared.

◆ setCurrentId()

void QtxComboBox::setCurrentId ( const QVariant &  ident)

Set current item by identifier.

Parameters
identitem's identifier

References index().

◆ setId()

void QtxComboBox::setId ( const int  idx,
const QVariant &  ident 
)

Assign identifier to specified item.

Parameters
idxitem's index
identitem's identifier

References IdRole.

Member Data Documentation

◆ myCleared

bool QtxComboBox::myCleared
private

"cleared" state


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