Drop-down tool button that behaves like a drop-down combo-box. More...
#include <QtxToolButton.h>
Public Slots | |
void | clear () |
Clear widget. More... | |
void | setCurrentIndex (int) |
Set current item by given index. More... | |
void | setCurrentText (const QString &) |
Set current item by given text. More... | |
Signals | |
void | activated (int) |
void | activated (const QString &) |
void | currentIndexChanged (int) |
void | currentIndexChanged (const QString &) |
void | currentTextChanged (const QString &) |
Public Member Functions | |
QtxToolButton (QWidget *=0) | |
Constructor. More... | |
virtual | ~QtxToolButton () |
Destructor. More... | |
int | addItem (const QString &, const QVariant &=QVariant()) |
Add an item with the given text, and containing the specified userData. The item is appended to the list of existing items. More... | |
int | addItem (const QIcon &, const QString &, const QVariant &=QVariant()) |
Add an item with the given icon and text, and containing the specified userData. The item is appended to the list of existing items. More... | |
void | addItems (const QStringList &) |
Add items with given texts. Each item is appended to the list of existing items in turn. More... | |
int | addSeparator (const QString &=QString()) |
Add separator to the end of the items list. More... | |
int | addSeparator (const QIcon &, const QString &) |
Add separator to the end of the items list. More... | |
void | removeItem (int) |
Remove item with given index. More... | |
int | count () const |
Get the number of items. More... | |
QVariant | currentData () const |
Get data of the current item. More... | |
int | currentIndex () const |
Get index of current item. More... | |
QString | currentText () const |
Get text of current item. More... | |
QVariant | itemData (int) const |
Get custom data of the item at given index. More... | |
QIcon | itemIcon (int) const |
Get icon of the item at given index. More... | |
QString | itemText (int) const |
Get text of the item at given index. More... | |
void | setItemData (int, const QVariant &) |
Set custom data of the item at given index. More... | |
void | setItemIcon (int, const QIcon &) |
Set icon of the item at given index. More... | |
void | setItemText (int, const QString &) |
Set text of the item at given index. More... | |
int | findText (const QString &) |
Search item with given text. More... | |
Protected Member Functions | |
void | keyPressEvent (QKeyEvent *) |
Reimplemented from QToolButton::keyPressEvent(). Process key press event. More... | |
void | wheelEvent (QWheelEvent *) |
Reimplemented from QToolButton::wheelEvent(). Process mouse wheel event. More... | |
Private Types | |
enum | Move { NoMove =0 , MoveUp , MoveDown , MoveFirst , MoveLast } |
Private Slots | |
void | actionTriggered (QAction *) |
Called when menu action is triggered. More... | |
Private Member Functions | |
void | internalUpdate () |
Update content of the widget. More... | |
QAction * | actionAt (int) const |
Get menu action at given index. More... | |
void | moveIndex (Move) |
Move current index. More... | |
void | emitCurrentChanged (bool, bool) |
Emit currentChanged() signal. More... | |
Drop-down tool button that behaves like a drop-down combo-box.
In contrast to the standard combo box, QtxToolButton can show drop-down menu containing groups of items where each group has a separate title.
|
private |
QtxToolButton::QtxToolButton | ( | QWidget * | parent = 0 | ) |
|
virtual |
Destructor.
|
private |
Get menu action at given index.
References count().
|
privateslot |
Called when menu action is triggered.
References currentIndex(), emitCurrentChanged(), and internalUpdate().
|
signal |
|
signal |
int QtxToolButton::addItem | ( | const QIcon & | icon, |
const QString & | text, | ||
const QVariant & | userData = QVariant() |
||
) |
Add an item with the given icon and text, and containing the specified userData. The item is appended to the list of existing items.
text | Item's text. |
icon | Item's icon. |
userData | Item's data. |
References count(), emitCurrentChanged(), and internalUpdate().
int QtxToolButton::addItem | ( | const QString & | text, |
const QVariant & | userData = QVariant() |
||
) |
Add an item with the given text, and containing the specified userData. The item is appended to the list of existing items.
text | Item's text. |
userData | Item's data. |
References count(), emitCurrentChanged(), and internalUpdate().
void QtxToolButton::addItems | ( | const QStringList & | texts | ) |
Add items with given texts. Each item is appended to the list of existing items in turn.
texts | Items being added. |
References count(), emitCurrentChanged(), and internalUpdate().
int QtxToolButton::addSeparator | ( | const QIcon & | icon, |
const QString & | text | ||
) |
Add separator to the end of the items list.
icon | Separator's icon. |
text | Separator's text. |
References actionAt(), and count().
int QtxToolButton::addSeparator | ( | const QString & | text = QString() | ) |
Add separator to the end of the items list.
text | Separator's text. |
References actionAt(), and count().
|
slot |
Clear widget.
References emitCurrentChanged(), and internalUpdate().
int QtxToolButton::count | ( | ) | const |
Get the number of items.
QVariant QtxToolButton::currentData | ( | ) | const |
Get data of the current item.
int QtxToolButton::currentIndex | ( | ) | const |
Get index of current item.
|
signal |
|
signal |
QString QtxToolButton::currentText | ( | ) | const |
Get text of current item.
|
signal |
|
private |
Emit currentChanged()
signal.
References activated(), currentIndexChanged(), and currentTextChanged().
int QtxToolButton::findText | ( | const QString & | text | ) |
Search item with given text.
Item's | text. |
References actionAt(), and count().
|
private |
Update content of the widget.
QVariant QtxToolButton::itemData | ( | int | index | ) | const |
Get custom data of the item at given index.
index | Item's index. |
References actionAt().
QIcon QtxToolButton::itemIcon | ( | int | index | ) | const |
Get icon of the item at given index.
index | Item's index. |
References actionAt().
QString QtxToolButton::itemText | ( | int | index | ) | const |
Get text of the item at given index.
index | Item's index. |
References actionAt().
|
protected |
|
private |
Move current index.
References actionAt(), count(), currentIndex(), emitCurrentChanged(), internalUpdate(), MoveDown, MoveFirst, MoveLast, and MoveUp.
void QtxToolButton::removeItem | ( | int | index | ) |
Remove item with given index.
index | Index of item to be removed. |
References actionAt(), count(), emitCurrentChanged(), and internalUpdate().
|
slot |
Set current item by given index.
index | Item's index. |
References actionAt(), count(), currentIndex(), emitCurrentChanged(), and internalUpdate().
|
slot |
Set current item by given text.
index | Item's index. |
References findText(), and setCurrentIndex().
void QtxToolButton::setItemData | ( | int | index, |
const QVariant & | value | ||
) |
Set custom data of the item at given index.
index | Item's index. |
value | Item's data. |
References actionAt().
void QtxToolButton::setItemIcon | ( | int | index, |
const QIcon & | icon | ||
) |
Set icon of the item at given index.
index | Item's index. |
icon | Item's icon. |
References actionAt(), and internalUpdate().
void QtxToolButton::setItemText | ( | int | index, |
const QString & | text | ||
) |
Set text of the item at given index.
index | Item's index. |
text | Item's text. |
References actionAt(), currentTextChanged(), and internalUpdate().
|
protected |