QComboBox Class Reference


The QComboBox widget is a combined button and popup list. More...

#include <qcombo.h>

Inherits QWidget.

List of all member functions.

Public Members

Signals

Protected Members


Detailed Description

The QComboBox widget is a combined button and popup list.

A combo box is a kind of popup menu that is opened by pressing a button. The popup list contains a number of text or pixmap items. The button displays the current item when the popup list is closed.

A combo box emits two signals, activated() and highlighted(), when a new item has been activated (selected) or highlighted (set to current).

Examples: tictac/tictac.cpp qmag/qmag.cpp widgets/widgets.cpp


Member Function Documentation

QComboBox::QComboBox ( QWidget *parent=0, const char *name=0)

Constructs a combo box widget with a parent and a name.

QComboBox::~QComboBox ()

Destroys the combo box.

void QComboBox::activated ( int index) [signal]

This signal is emitted when a new item has been activated (selected). The index is the position of the item in the popup list.

bool QComboBox::autoResize () const

Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is disabled.

Auto-resizing is disabled by default.

See also: setAutoResize().

void QComboBox::changeItem ( const QPixmap &im, int index)

Replaces the item at position index with a pixmap.

void QComboBox::changeItem ( const char *text, int index)

Replaces the item at position index with a text.

void QComboBox::clear ()

Removes all combo box items.

int QComboBox::count () const

Returns the number of items in the combo box.

int QComboBox::currentItem () const

Returns the current combo box item.

See also: setCurrentItem().

void QComboBox::highlighted ( int index) [signal]

This signal is emitted when a new item has been set to current. The index is the position of the item in the popup list.

void QComboBox::insertItem ( const QPixmap &pixmap, int index=-1)

Inserts a pixmap item at position index. The item will be appended if index is negative.

void QComboBox::insertItem ( const char *text, int index=-1)

Inserts a text item at position index. The item will be appended if index is negative.

Examples: widgets/widgets.cpp

void QComboBox::insertStrList ( const QStrList *list, int index=-1)

Inserts the list of strings at the index index in the combo box.

Examples: qmag/qmag.cpp

void QComboBox::insertStrList ( const char **strings, int numStrings=-1, int index=-1)

Inserts the array of strings at the index index in the combo box.

The numStrings argument is the number of strings. If numStrings is -1 (default), the strs array must be terminated with 0.

Example:

    static const char *items[] = { "red", "green", "blue", 0 };
    combo->insertStrList( items );

void QComboBox::keyPressEvent ( QKeyEvent *e) [virtual protected]

Handles key press events for the combo box. Only Enter and Return are accepted.

Reimplemented from QWidget.

void QComboBox::mouseDoubleClickEvent ( QMouseEvent *e) [virtual protected]

Handles mouse double click events for the combo box.

Reimplemented from QWidget.

void QComboBox::mouseMoveEvent ( QMouseEvent *) [virtual protected]

Handles mouse move events for the combo box.

Reimplemented from QWidget.

void QComboBox::mousePressEvent ( QMouseEvent *e) [virtual protected]

Handles mouse press events for the combo box.

Reimplemented from QWidget.

void QComboBox::mouseReleaseEvent ( QMouseEvent *) [virtual protected]

Handles mouse release events for the combo box.

Reimplemented from QWidget.

void QComboBox::paintEvent ( QPaintEvent *) [virtual protected]

Handles paint events for the combo box.

Reimplemented from QWidget.

const QPixmap * QComboBox::pixmap ( int index) const

Returns the pixmap item at a given index, or 0 if the item is not a pixmap.

void QComboBox::popup () [protected]

Popups the combo box popup list.

void QComboBox::removeItem ( int index)

Removes the item at position index.

void QComboBox::setAutoResize ( bool enable)

Enables auto-resizing if enable is TRUE, or disables it if enable is FALSE.

When auto-resizing is enabled, the combo box button will resize itself whenever the current combo box item change.

See also: autoResize() and adjustSize().

Examples: widgets/widgets.cpp

void QComboBox::setBackgroundColor ( const QColor &color) [virtual]

Reimplements QWidget::setBackgroundColor().

Sets the background color for both the combo box button and the combo box popup list.

Reimplemented from QWidget.

void QComboBox::setCurrentItem ( int index)

Sets the current combo box item. This is the item to be displayed on the combo box button.

See also: currentItem().

void QComboBox::setFont ( const QFont &font) [virtual]

Reimplements QWidget::setFont().

Sets the font for both the combo box button and the combo box popup list.

Reimplemented from QWidget.

void QComboBox::setPalette ( const QPalette &palette) [virtual]

Reimplements QWidget::setPalette().

Sets the palette for both the combo box button and the combo box popup list.

Reimplemented from QWidget.

QSize QComboBox::sizeHint () const [virtual]

Returns a size which fits the contents of the combo box button.

Reimplemented from QWidget.

const char * QComboBox::text ( int index) const

Returns the text item at a given index, or 0 if the item is not a string.


This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:51, 1996/09/24 for Qt version 1.0 by the webmaster at Troll Tech