Enhanced version of Qt combo box class. More...
#include <QtxComboBox.h>
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... | |
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.
QtxComboBox::QtxComboBox | ( | QWidget * | parent = 0 | ) |
parent | parent widget |
References onCurrentChanged().
|
virtual |
|
signal |
ident | item's identifier |
|
signal |
ident | item's identifier |
|
signal |
ident | item's identifier |
|
protectedvirtual |
e | child event |
QVariant QtxComboBox::currentId | ( | ) | const |
References id().
|
protectedvirtual |
e | custom event |
References CLEAR_EVENT, and myCleared.
bool QtxComboBox::hasId | ( | const int | idx | ) | const |
idx | item's index |
true
if item with given index has identifier of false
otherwise References IdRole.
QVariant QtxComboBox::id | ( | const int | idx | ) | const |
idx | item's index |
References IdRole.
int QtxComboBox::index | ( | const QVariant & | ident | ) | const |
ident | item's identifier |
References IdRole.
bool QtxComboBox::isCleared | ( | ) | const |
true
if combo box is in "cleared" state or false
otherwise References myCleared.
|
privateslot |
idx | index of item being set current |
References activatedId(), id(), and resetClear().
|
protectedvirtual |
e | paint event |
References myCleared, and QtxComboBox::Model::setCleared().
|
private |
References myCleared.
void QtxComboBox::setCleared | ( | const bool | isClear | ) |
isClear | new "cleared" state |
References myCleared.
void QtxComboBox::setCurrentId | ( | const QVariant & | ident | ) |
ident | item's identifier |
References index().
idx | item's index |
ident | item's identifier |
References IdRole.
|
private |