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

Drop-down tool button that behaves like a drop-down combo-box. More...

#include <QtxToolButton.h>

Inheritance diagram for QtxToolButton:
Inheritance graph

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...
 
QActionactionAt (int) const
 Get menu action at given index. More...
 
void moveIndex (Move)
 Move current index. More...
 
void emitCurrentChanged (bool, bool)
 Emit currentChanged() signal. More...
 

Detailed Description

In contrast to the standard combo box, QtxToolButton can show drop-down menu containing groups of items where each group has a separate title.

Member Enumeration Documentation

enum QtxToolButton::Move
private
Enumerator
NoMove 
MoveUp 
MoveDown 
MoveFirst 
MoveLast 

Constructor & Destructor Documentation

QtxToolButton::QtxToolButton ( QWidget parent = 0)
Parameters
parentParent widget.

References actionTriggered().

QtxToolButton::~QtxToolButton ( )
virtual

Member Function Documentation

QAction * QtxToolButton::actionAt ( int  index) const
private

References count().

void QtxToolButton::actionTriggered ( QAction action)
privateslot
void QtxToolButton::activated ( int  )
signal
void QtxToolButton::activated ( const QString &  )
signal
int QtxToolButton::addItem ( const QString &  text,
const QVariant &  userData = QVariant() 
)
Parameters
textItem's text.
userDataItem's data.
Returns
Index of just added item.

References count(), emitCurrentChanged(), and internalUpdate().

int QtxToolButton::addItem ( const QIcon &  icon,
const QString &  text,
const QVariant &  userData = QVariant() 
)
Parameters
textItem's text.
iconItem's icon.
userDataItem's data.
Returns
Index of just added item.

References count(), emitCurrentChanged(), and internalUpdate().

void QtxToolButton::addItems ( const QStringList &  texts)
Parameters
textsItems being added.

References count(), emitCurrentChanged(), and internalUpdate().

int QtxToolButton::addSeparator ( const QString &  text = QString())
Parameters
textSeparator's text.
Returns
Index of just added item.

References actionAt(), and count().

int QtxToolButton::addSeparator ( const QIcon &  icon,
const QString &  text 
)
Parameters
iconSeparator's icon.
textSeparator's text.
Returns
Index of just added item.

References actionAt(), and count().

void QtxToolButton::clear ( )
slot
int QtxToolButton::count ( ) const
Returns
Number of items.
QVariant QtxToolButton::currentData ( ) const
Returns
Current item's data (invalid QVariant if list of items is empty or current item doesn't have data).
int QtxToolButton::currentIndex ( ) const
Returns
Current item's index; -1 if list of items is empty or if there's no current item.
void QtxToolButton::currentIndexChanged ( int  )
signal
void QtxToolButton::currentIndexChanged ( const QString &  )
signal
QString QtxToolButton::currentText ( ) const
Returns
Current item's text; null sting if list of items is empty or if there's no current item.
void QtxToolButton::currentTextChanged ( const QString &  )
signal
void QtxToolButton::emitCurrentChanged ( bool  activate,
bool  changed 
)
private
int QtxToolButton::findText ( const QString &  text)
Parameters
Item'stext.
Returns
Item's index; -1 if item is not found.

References actionAt(), and count().

void QtxToolButton::internalUpdate ( )
private
QVariant QtxToolButton::itemData ( int  index) const
Parameters
indexItem's index.
Returns
Item's data (invalid QVariant if index is out of range).

References actionAt().

QIcon QtxToolButton::itemIcon ( int  index) const
Parameters
indexItem's index.
Returns
Item's icon.

References actionAt().

QString QtxToolButton::itemText ( int  index) const
Parameters
indexItem's index.
Returns
Item's text.

References actionAt().

void QtxToolButton::keyPressEvent ( QKeyEvent *  e)
protected
Parameters
eKey press event.

References MoveDown, MoveFirst, moveIndex(), MoveLast, MoveUp, and NoMove.

void QtxToolButton::moveIndex ( Move  move)
private
void QtxToolButton::removeItem ( int  index)
Parameters
indexIndex of item to be removed.

References actionAt(), count(), emitCurrentChanged(), and internalUpdate().

void QtxToolButton::setCurrentIndex ( int  index)
slot
Parameters
indexItem's index.

References actionAt(), count(), currentIndex(), emitCurrentChanged(), and internalUpdate().

void QtxToolButton::setCurrentText ( const QString &  text)
slot
Parameters
indexItem's index.

References findText(), and setCurrentIndex().

void QtxToolButton::setItemData ( int  index,
const QVariant &  value 
)
Parameters
indexItem's index.
valueItem's data.

References actionAt().

void QtxToolButton::setItemIcon ( int  index,
const QIcon &  icon 
)
Parameters
indexItem's index.
iconItem's icon.

References actionAt(), and internalUpdate().

void QtxToolButton::setItemText ( int  index,
const QString &  text 
)
Parameters
indexItem's index.
textItem's text.

References actionAt(), currentTextChanged(), and internalUpdate().

void QtxToolButton::wheelEvent ( QWheelEvent *  e)
protected
Parameters
eMouse wheel event.

References MoveDown, MoveFirst, moveIndex(), MoveLast, MoveUp, and NoMove.


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