Qtopia library API Documentation

MenuButton Class Reference

The MenuButton class is a pushbutton with a menu. More...

#include <menubutton.h>

Inheritance diagram for MenuButton:

Inheritance graph
[legend]
Collaboration diagram for MenuButton:

Collaboration graph
[legend]
List of all members.

Public Slots

void select (int)
void select (const QString &)

Signals

void selected (int)
void selected (const QString &)

Public Member Functions

 MenuButton (QWidget *parent, const char *name=0)
 MenuButton (const QStringList &items, QWidget *parent, const char *name=0)
void clear ()
int currentItem () const
QString currentText () const
void insertItems (const QStringList &items)
void insertItem (const QIconSet &icon, const QString &text=QString::null)
void insertItem (const QString &text)
void insertSeparator ()
void setLabel (const QString &label)
int count ()
void remove (int id)
QString text (int id)
void setUseLabel (bool b)

Detailed Description

The MenuButton class is a pushbutton with a menu.

When the user presses the menubutton's pushbutton, the menu pops up. A menu is composed of menu items each of which has a string label, and optionally an icon.

The index of the item that the user's input device (e.g. stylus) is pointing at is the currentItem(), whose text is available using currentText().

Menu items are inserted with the constructor, insertItem() or insertItems(). Separators are inserted with insertSeparator(). All the items in the menu can be removed by calling clear().

Items can be selected programmatically using select(). When a menu item is selected (programmatically or by the user), the selected() signal is emitted.

Definition at line 26 of file menubutton.h.


Constructor & Destructor Documentation

MenuButton::MenuButton QWidget parent,
const char *  name = 0
 

Constructs an empty MenuButton. The standard parent an name arguments are passed to the base class.

See also:
insertItem() insertItems()

Definition at line 81 of file menubutton.cpp.

MenuButton::MenuButton const QStringList items,
QWidget parent,
const char *  name = 0
 

Constructs a MenuButton. A menu item is created (see insertItem() and insertItems()) for each string in the items string list. The standard parent an name arguments are passed to the base class.

Definition at line 67 of file menubutton.cpp.

References insertItems().


Member Function Documentation

void MenuButton::clear  ) 
 

Removes all the menu items from the button and menu.

Definition at line 100 of file menubutton.cpp.

int MenuButton::currentItem  )  const
 

Returns the index position of the current item.

Definition at line 186 of file menubutton.cpp.

QString MenuButton::currentText  )  const
 

Returns the label text of the current item.

Definition at line 194 of file menubutton.cpp.

References QPopupMenu::text().

Referenced by select().

void MenuButton::insertItems const QStringList items  ) 
 

A menu item is created (see insertItem()) for each string in the items string list. If any string is "--" a separator (see insertSeparator()) is inserted in its place.

Definition at line 111 of file menubutton.cpp.

References QValueList::begin(), QValueList::end(), insertItem(), and insertSeparator().

Referenced by MenuButton().

void MenuButton::insertItem const QIconSet icon,
const QString text = QString::null
 

Inserts a menu item with the icon icon and label text into the menu.

See also:
insertItems()

Definition at line 128 of file menubutton.cpp.

References QPopupMenu::insertItem().

Referenced by insertItems().

void MenuButton::insertItem const QString text  ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Inserts a menu item with the label text into the menu.

See also:
insertItems()

Definition at line 140 of file menubutton.cpp.

References QPopupMenu::insertItem().

void MenuButton::insertSeparator  ) 
 

Inserts a separator into the menu.

See also:
insertItems()

Definition at line 151 of file menubutton.cpp.

References QPopupMenu::insertSeparator().

Referenced by insertItems().

void MenuButton::setLabel const QString label  ) 
 

Sets the menubutton's label. If label is empty, the current item text is displayed, otherwise label should contain "%1", which will be replaced by the current item text.

Definition at line 204 of file menubutton.cpp.

int MenuButton::count  ) 
 

return count of items in menu

Definition at line 234 of file menubutton.cpp.

void MenuButton::remove int  id  ) 
 

remove item at id

Definition at line 225 of file menubutton.cpp.

References QPopupMenu::removeItem().

QString MenuButton::text int  id  ) 
 

returns text of item id

Definition at line 242 of file menubutton.cpp.

References QPopupMenu::text().

void MenuButton::setUseLabel bool  b  ) 
 

sets true or false the use of label

Definition at line 250 of file menubutton.cpp.

void MenuButton::selected int  index  )  [signal]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This signal is emitted when the item at position index is selected.

Referenced by select().

void MenuButton::selected const QString text  )  [signal]
 

This signal is emitted when the item with the label text is selected.

void MenuButton::select int  s  )  [slot]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Selects the item at index position s.

Definition at line 173 of file menubutton.cpp.

References currentText(), QPopupMenu::iconSet(), selected(), and QPushButton::setIconSet().

Referenced by select().

void MenuButton::select const QString s  )  [slot]
 

Selects the items with label text s.

Definition at line 159 of file menubutton.cpp.

References select(), and QPopupMenu::text().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:24 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001