Eneboo - Documentación para desarrolladores
Tipos públicos | Slots públicos | Señales | Métodos públicos | Métodos protegidos | Propiedades
Referencia de la Clase QComboBox

The QComboBox widget is a combined button and popup list. Más...

#include <qcombobox.h>

Diagrama de herencias de QComboBox
QWidget QWidget QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject EnumBox

Lista de todos los miembros.

Tipos públicos

enum  Policy {
  NoInsertion, AtTop, AtCurrent, AtBottom,
  AfterCurrent, BeforeCurrent, NoInsertion, AtTop,
  AtCurrent, AtBottom, AfterCurrent, BeforeCurrent
}
enum  Policy {
  NoInsertion, AtTop, AtCurrent, AtBottom,
  AfterCurrent, BeforeCurrent, NoInsertion, AtTop,
  AtCurrent, AtBottom, AfterCurrent, BeforeCurrent
}

Slots públicos

void clear ()
void clearValidator ()
void clearEdit ()
virtual void setEditText (const QString &)
void clear ()
void clearValidator ()
void clearEdit ()
virtual void setEditText (const QString &)

Señales

void activated (int index)
void highlighted (int index)
void activated (const QString &)
void highlighted (const QString &)
void textChanged (const QString &)
void activated (int index)
void highlighted (int index)
void activated (const QString &)
void highlighted (const QString &)
void textChanged (const QString &)

Métodos públicos

 QComboBox (QWidget *parent=0, const char *name=0)
 QComboBox (bool rw, QWidget *parent=0, const char *name=0)
 ~QComboBox ()
int count () const
void insertStringList (const QStringList &, int index=-1)
void insertStrList (const QStrList &, int index=-1)
void insertStrList (const QStrList *, int index=-1)
void insertStrList (const char **, int numStrings=-1, int index=-1)
void insertItem (const QString &text, int index=-1)
void insertItem (const QPixmap &pixmap, int index=-1)
void insertItem (const QPixmap &pixmap, const QString &text, int index=-1)
void removeItem (int index)
int currentItem () const
virtual void setCurrentItem (int index)
QString currentText () const
virtual void setCurrentText (const QString &)
QString text (int index) const
const QPixmappixmap (int index) const
void changeItem (const QString &text, int index)
void changeItem (const QPixmap &pixmap, int index)
void changeItem (const QPixmap &pixmap, const QString &text, int index)
bool autoResize () const
virtual void setAutoResize (bool)
QSize sizeHint () const
void setPalette (const QPalette &)
void setFont (const QFont &)
void setEnabled (bool)
virtual void setSizeLimit (int)
int sizeLimit () const
virtual void setMaxCount (int)
int maxCount () const
virtual void setInsertionPolicy (Policy policy)
Policy insertionPolicy () const
virtual void setValidator (const QValidator *)
const QValidatorvalidator () const
virtual void setListBox (QListBox *)
QListBoxlistBox () const
virtual void setLineEdit (QLineEdit *edit)
QLineEditlineEdit () const
virtual void setAutoCompletion (bool)
bool autoCompletion () const
bool eventFilter (QObject *object, QEvent *event)
void setDuplicatesEnabled (bool enable)
bool duplicatesEnabled () const
bool editable () const
void setEditable (bool)
virtual void popup ()
void hide ()
 QComboBox (QWidget *parent=0, const char *name=0)
 QComboBox (bool rw, QWidget *parent=0, const char *name=0)
 ~QComboBox ()
int count () const
void insertStringList (const QStringList &, int index=-1)
void insertStrList (const QStrList &, int index=-1)
void insertStrList (const QStrList *, int index=-1)
void insertStrList (const char **, int numStrings=-1, int index=-1)
void insertItem (const QString &text, int index=-1)
void insertItem (const QPixmap &pixmap, int index=-1)
void insertItem (const QPixmap &pixmap, const QString &text, int index=-1)
void removeItem (int index)
int currentItem () const
virtual void setCurrentItem (int index)
QString currentText () const
virtual void setCurrentText (const QString &)
QString text (int index) const
const QPixmappixmap (int index) const
void changeItem (const QString &text, int index)
void changeItem (const QPixmap &pixmap, int index)
void changeItem (const QPixmap &pixmap, const QString &text, int index)
bool autoResize () const
virtual void setAutoResize (bool)
QSize sizeHint () const
void setPalette (const QPalette &)
void setFont (const QFont &)
void setEnabled (bool)
virtual void setSizeLimit (int)
int sizeLimit () const
virtual void setMaxCount (int)
int maxCount () const
virtual void setInsertionPolicy (Policy policy)
Policy insertionPolicy () const
virtual void setValidator (const QValidator *)
const QValidatorvalidator () const
virtual void setListBox (QListBox *)
QListBoxlistBox () const
virtual void setLineEdit (QLineEdit *edit)
QLineEditlineEdit () const
virtual void setAutoCompletion (bool)
bool autoCompletion () const
bool eventFilter (QObject *object, QEvent *event)
void setDuplicatesEnabled (bool enable)
bool duplicatesEnabled () const
bool editable () const
void setEditable (bool)
virtual void popup ()
void hide ()

Métodos protegidos

void paintEvent (QPaintEvent *)
void resizeEvent (QResizeEvent *)
void mousePressEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *e)
void focusInEvent (QFocusEvent *e)
void focusOutEvent (QFocusEvent *e)
void wheelEvent (QWheelEvent *e)
void styleChange (QStyle &)
void updateMask ()
void paintEvent (QPaintEvent *)
void resizeEvent (QResizeEvent *)
void mousePressEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseDoubleClickEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *e)
void focusInEvent (QFocusEvent *e)
void focusOutEvent (QFocusEvent *e)
void wheelEvent (QWheelEvent *e)
void styleChange (QStyle &)
void updateMask ()

Propiedades

bool editable
 whether the combobox is editable
int count
 the number of items in the combobox
QString currentText
 the text of the combobox's current item
int currentItem
 the index of the current item in the combobox
bool autoResize
 whether auto resize is enabled
int sizeLimit
 the maximum on-screen size of the combobox.
int maxCount
 the maximum number of items allowed in the combobox
Policy insertionPolicy
 the position of the items inserted by the user
bool autoCompletion
 whether auto-completion is enabled
bool duplicatesEnabled
 whether duplicates are allowed

Descripción detallada

The QComboBox widget is a combined button and popup list.

A combobox is a selection widget which displays the current item and can pop up a list of items. A combobox may be editable in which case the user can enter arbitrary strings.

Comboboxes provide a means of showing the user's current choice out of a list of options in a way that takes up the minimum amount of screen space.

QComboBox supports three different display styles: Aqua/Motif 1.x, Motif 2.0 and Windows. In Motif 1.x, a combobox was called XmOptionMenu. In Motif 2.0, OSF introduced an improved combobox and named that XmComboBox. QComboBox provides both.

QComboBox provides two different constructors. The simplest constructor creates an "old-style" combobox in Motif (or Aqua) style:

        QComboBox *c = new QComboBox( this, "read-only combobox" );

The other constructor creates a new-style combobox in Motif style, and can create both read-only and editable comboboxes:

        QComboBox *c1 = new QComboBox( FALSE, this, "read-only combobox" );
        QComboBox *c2 = new QComboBox( TRUE, this, "editable combobox" );

New-style comboboxes use a list box in both Motif and Windows styles, and both the content size and the on-screen size of the list box can be limited with sizeLimit() and setMaxCount() respectively. Old-style comboboxes use a popup in Aqua and Motif style, and that popup will happily grow larger than the desktop if you put enough data into it.

The two constructors create identical-looking comboboxes in Windows style.

Comboboxes can contain pixmaps as well as strings; the insertItem() and changeItem() functions are suitably overloaded. For editable comboboxes, the function clearEdit() is provided, to clear the displayed string without changing the combobox's contents.

A combobox emits two signals, activated() and highlighted(), when a new item has been activated (selected) or highlighted (made current). Both signals exist in two versions, one with a QString argument and one with an int argument. If the user highlights or activates a pixmap, only the int signals are emitted. Whenever the text of an editable combobox is changed the textChanged() signal is emitted.

When the user enters a new string in an editable combobox, the widget may or may not insert it, and it can insert it in several locations. The default policy is is AtBottom but you can change this using setInsertionPolicy().

It is possible to constrain the input to an editable combobox using QValidator; see setValidator(). By default, any input is accepted.

If the combobox is not editable then it has a default focusPolicy() of TabFocus, i.e. it will not grab focus if clicked. This differs from both Windows and Motif. If the combobox is editable then it has a default focusPolicy() of StrongFocus, i.e. it will grab focus if clicked.

A combobox can be populated using the insert functions, insertStringList() and insertItem() for example. Items can be changed with changeItem(). An item can be removed with removeItem() and all items can be removed with clear(). The text of the current item is returned by currentText(), and the text of a numbered item is returned with text(). The current item can be set with setCurrentItem() or setCurrentText(). The number of items in the combobox is returned by count(); the maximum number of items can be set with setMaxCount(). You can allow editing using setEditable(). For editable comboboxes you can set auto-completion using setAutoCompletion() and whether or not the user can add duplicates is set with setDuplicatesEnabled().

qcombo1-m.png

(Motif 1, read-only)

qcombo2-m.png

(Motif 2, editable)

qcombo3-m.png

(Motif 2, read-only)

qcombo1-w.png

(Windows style)

Depending on the style, QComboBox will use a QListBox or a QPopupMenu to display the list of items. See setListBox() for more information.

Ver también:
QLineEdit QListBox QSpinBox QRadioButton QButtonGroup GUI Design Handbook: Combo Box, GUI Design Handbook: Drop-Down List Box.

Documentación de las enumeraciones miembro de la clase

This enum specifies what the QComboBox should do when a new string is entered by the user.

NoInsertion the string will not be inserted into the combobox.

AtTop insert the string as the first item in the combobox.

AtCurrent replace the previously selected item with the string the user has entered.

AtBottom insert the string as the last item in the combobox.

AfterCurrent insert the string after the previously selected item.

BeforeCurrent insert the string before the previously selected item.

activated() is always emitted when the string is entered.

If inserting the new string would cause the combobox to breach its content size limit, the item at the other end of the list is deleted. The definition of "other end" is implementation-dependent.

Valores de enumeraciones:
NoInsertion 
AtTop 
AtCurrent 
AtBottom 
AfterCurrent 
BeforeCurrent 
NoInsertion 
AtTop 
AtCurrent 
AtBottom 
AfterCurrent 
BeforeCurrent 
Valores de enumeraciones:
NoInsertion 
AtTop 
AtCurrent 
AtBottom 
AfterCurrent 
BeforeCurrent 
NoInsertion 
AtTop 
AtCurrent 
AtBottom 
AfterCurrent 
BeforeCurrent 

Documentación del constructor y destructor

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

Constructs a combobox widget with parent parent called name.

This constructor creates a popup list if the program uses Motif (or Aqua) look and feel; this is compatible with Motif 1.x and Aqua.

Note: If you use this constructor to create your QComboBox, then the pixmap() function will always return 0. To workaround this, use the other constructor.

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

Constructs a combobox with a maximum size and either Motif 2.0 or Windows look and feel.

The input field can be edited if rw is TRUE, otherwise the user may only choose one of the items in the combobox.

The parent and name arguments are passed on to the QWidget constructor.

QComboBox::~QComboBox ( )

Destroys the combobox.

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

Documentación de las funciones miembro

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 combobox.

This signal is not emitted if the item is changed programmatically, e.g. using setCurrentItem().

void QComboBox::activated ( const QString string) [signal]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

This signal is emitted when a new item has been activated (selected). string is the selected string.

You can also use the activated(int) signal, but be aware that its argument is meaningful only for selected strings, not for user entered strings.

void QComboBox::activated ( int  index) [signal]
void QComboBox::activated ( const QString ) [signal]
bool QComboBox::autoCompletion ( ) const
bool QComboBox::autoCompletion ( ) const
bool QComboBox::autoResize ( ) const
bool QComboBox::autoResize ( ) const
void QComboBox::changeItem ( const QString t,
int  index 
)

Replaces the item at position index with the text t.

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

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Replaces the item at position index with the pixmap im, unless the combobox is editable.

Ver también:
insertItem()
void QComboBox::changeItem ( const QPixmap im,
const QString t,
int  index 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Replaces the item at position index with the pixmap im and the text t.

Ver también:
insertItem()
void QComboBox::changeItem ( const QString text,
int  index 
)
void QComboBox::changeItem ( const QPixmap pixmap,
int  index 
)
void QComboBox::changeItem ( const QPixmap pixmap,
const QString text,
int  index 
)
void QComboBox::clear ( void  ) [slot]

Removes all combobox items.

void QComboBox::clear ( ) [slot]
void QComboBox::clearEdit ( ) [slot]

Clears the line edit without changing the combobox's contents. Does nothing if the combobox isn't editable.

This is particularly useful when using a combobox as a line edit with history. For example you can connect the combobox's activated() signal to clearEdit() in order to present the user with a new, empty line as soon as Enter is pressed.

Ver también:
setEditText()
void QComboBox::clearEdit ( ) [slot]
void QComboBox::clearValidator ( ) [slot]

This slot is equivalent to setValidator( 0 ).

void QComboBox::clearValidator ( ) [slot]
int QComboBox::count ( ) const
int QComboBox::count ( ) const
int QComboBox::currentItem ( ) const
int QComboBox::currentItem ( ) const
QString QComboBox::currentText ( ) const
QString QComboBox::currentText ( ) const
bool QComboBox::duplicatesEnabled ( ) const
bool QComboBox::duplicatesEnabled ( ) const
bool QComboBox::editable ( ) const
bool QComboBox::editable ( ) const
bool QComboBox::eventFilter ( QObject object,
QEvent event 
) [virtual]

Reimplementado de QObject.

bool QComboBox::eventFilter ( QObject ,
QEvent  
) [virtual]

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.

Example:

    class MyMainWindow : public QMainWindow
    {
    public:
        MyMainWindow( QWidget *parent = 0, const char *name = 0 );

    protected:
        bool eventFilter( QObject *obj, QEvent *ev );

    private:
        QTextEdit *textEdit;
    };

    MyMainWindow::MyMainWindow( QWidget *parent, const char *name )
        : QMainWindow( parent, name )
    {
        textEdit = new QTextEdit( this );
        setCentralWidget( textEdit );
        textEdit->installEventFilter( this );
    }

    bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev )
    {
        if ( obj == textEdit ) {
            if ( e->type() == QEvent::KeyPress ) {
                QKeyEvent *k = (QKeyEvent*)ev;
                qDebug( "Ate key press %d", k->key() );
                return TRUE;
            } else {
                return FALSE;
            }
        } else {
            // pass the event on to the parent class
            return QMainWindow::eventFilter( obj, ev );
        }
    }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Atención:
If you delete the receiver object in this function, be sure to return TRUE. Otherwise, Qt will forward the event to the deleted object and the program might crash.
Ver también:
installEventFilter()

Reimplementado de QObject.

void QComboBox::focusInEvent ( QFocusEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget.

A widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.

Ver también:
focusOutEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplementado de QWidget.

void QComboBox::focusInEvent ( QFocusEvent e) [protected, virtual]

Reimplementado de QWidget.

void QComboBox::focusOutEvent ( QFocusEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget.

A widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.

Ver también:
focusInEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplementado de QWidget.

void QComboBox::focusOutEvent ( QFocusEvent e) [protected, virtual]

Reimplementado de QWidget.

void QComboBox::hide ( ) [virtual]

Reimplementado de QWidget.

void QComboBox::hide ( ) [virtual]

Hides the widget.

You almost never have to reimplement this function. If you need to do something after a widget is hidden, use hideEvent() instead.

Ver también:
hideEvent(), isHidden(), show(), showMinimized(), isVisible(), close()

Reimplementado de QWidget.

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

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

This signal is not emitted if the item is changed programmatically, e.g. using setCurrentItem().

void QComboBox::highlighted ( const QString string) [signal]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.

This signal is emitted when a new item has been set to be the current item. string is the item's text.

You can also use the highlighted(int) signal.

void QComboBox::highlighted ( int  index) [signal]
void QComboBox::highlighted ( const QString ) [signal]
Policy QComboBox::insertionPolicy ( ) const
Policy QComboBox::insertionPolicy ( ) const
void QComboBox::insertItem ( const QString text,
int  index = -1 
)
void QComboBox::insertItem ( const QPixmap pixmap,
int  index = -1 
)
void QComboBox::insertItem ( const QPixmap pixmap,
const QString text,
int  index = -1 
)
void QComboBox::insertItem ( const QPixmap pixmap,
const QString text,
int  index = -1 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts a pixmap item with additional text text at position index. The item will be appended if index is negative.

void QComboBox::insertItem ( const QString t,
int  index = -1 
)

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

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

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts a pixmap item at position index. The item will be appended if index is negative.

void QComboBox::insertStringList ( const QStringList list,
int  index = -1 
)

Inserts the list of strings at position index in the combobox.

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

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts the list of strings at position index in the combobox.

This is only for compatibility since it does not support Unicode strings. See insertStringList().

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

Inserts the array of char * strings at position index in the combobox.

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

Example:

        static const char* items[] = { "red", "green", "blue", 0 };
        combo->insertStrList( items );
Ver también:
insertStringList()
void QComboBox::insertStrList ( const QStrList list,
int  index = -1 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts the list of strings at position index in the combobox.

This is only for compatibility since it does not support Unicode strings. See insertStringList().

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

This event handler, for event e, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you explicitly ignore the event if you do not understand it, so that the widget's parent can interpret it; otherwise, the event will be implicitly accepted. Although top-level widgets are able to choose whether to accept or ignore unknown events because they have no parent widgets that could otherwise handle them, it is good practice to explicitly ignore events to make widgets as reusable as possible.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

Ver también:
keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent

Reimplementado de QWidget.

Reimplementado en EnumBox.

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

Reimplementado de QWidget.

Reimplementado en EnumBox.

QLineEdit * QComboBox::lineEdit ( ) const

Returns the line edit, or 0 if there is no line edit.

Only editable listboxes have a line editor.

QLineEdit* QComboBox::lineEdit ( ) const
QListBox * QComboBox::listBox ( ) const

Returns the current list box, or 0 if there is no list box. (QComboBox can use QPopupMenu instead of QListBox.) Provided to match setListBox().

Ver también:
setListBox()
QListBox* QComboBox::listBox ( ) const
int QComboBox::maxCount ( ) const
int QComboBox::maxCount ( ) const
void QComboBox::mouseDoubleClickEvent ( QMouseEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive mouse double click events for the widget.

The default implementation generates a normal mouse press event.

Note that the widgets gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent().

Ver también:
mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(), event(), QMouseEvent

Reimplementado de QWidget.

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

Reimplementado de QWidget.

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

Reimplementado de QWidget.

void QComboBox::mouseMoveEvent ( QMouseEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.

Ver también:
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent

Reimplementado de QWidget.

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

This event handler, for event e, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

Ver también:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplementado de QWidget.

Reimplementado en EnumBox.

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

Reimplementado de QWidget.

Reimplementado en EnumBox.

void QComboBox::mouseReleaseEvent ( QMouseEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive mouse release events for the widget.

Ver también:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplementado de QWidget.

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

Reimplementado de QWidget.

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

Reimplementado de QWidget.

Reimplementado en EnumBox.

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

This event handler can be reimplemented in a subclass to receive paint events.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.

The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it.

Ver también:
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent

Reimplementado de QWidget.

Reimplementado en EnumBox.

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

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

void QComboBox::popup ( ) [virtual]

Pops up the combobox popup list.

If the list is empty, no items appear.

virtual void QComboBox::popup ( ) [virtual]
void QComboBox::removeItem ( int  index)

Removes the item at position index.

void QComboBox::removeItem ( int  index)
void QComboBox::resizeEvent ( QResizeEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().

The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.

Widgets that have been created with the WNoAutoErase flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.

The default implementation calls updateMask() if the widget has automatic masking enabled.

Ver también:
moveEvent(), event(), resize(), QResizeEvent, paintEvent()

Reimplementado de QWidget.

void QComboBox::resizeEvent ( QResizeEvent e) [protected, virtual]

Reimplementado de QWidget.

virtual void QComboBox::setAutoCompletion ( bool  ) [virtual]
void QComboBox::setAutoCompletion ( bool  enable) [virtual]
void QComboBox::setAutoResize ( bool  enable) [virtual]
virtual void QComboBox::setAutoResize ( bool  ) [virtual]
virtual void QComboBox::setCurrentItem ( int  index) [virtual]
void QComboBox::setCurrentItem ( int  index) [virtual]
virtual void QComboBox::setCurrentText ( const QString ) [virtual]
void QComboBox::setCurrentText ( const QString txt) [virtual]
void QComboBox::setDuplicatesEnabled ( bool  enable)
void QComboBox::setDuplicatesEnabled ( bool  enable)
void QComboBox::setEditable ( bool  y)
void QComboBox::setEditable ( bool  )
virtual void QComboBox::setEditText ( const QString ) [virtual, slot]
void QComboBox::setEditText ( const QString newText) [virtual, slot]

Sets the text in the line edit to newText without changing the combobox's contents. Does nothing if the combobox isn't editable.

This is useful e.g. for providing a good starting point for the user's editing and entering the change in the combobox only when the user presses Enter.

Ver también:
clearEdit() insertItem()
void QComboBox::setEnabled ( bool  enable) [virtual]

Reimplementado de QWidget.

void QComboBox::setEnabled ( bool  ) [virtual]

Reimplementado de QWidget.

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

Reimplementado de QWidget.

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

Sets the font for both the combobox button and the combobox popup list to font.

Reimplementado de QWidget.

virtual void QComboBox::setInsertionPolicy ( Policy  policy) [virtual]
void QComboBox::setInsertionPolicy ( Policy  policy) [virtual]
virtual void QComboBox::setLineEdit ( QLineEdit edit) [virtual]
void QComboBox::setLineEdit ( QLineEdit edit) [virtual]

Sets the line edit to use edit instead of the current line edit.

void QComboBox::setListBox ( QListBox newListBox) [virtual]

Sets the combobox to use newListBox instead of the current list box or popup. As a side effect, it clears the combobox of its current contents.

Atención:
QComboBox assumes that newListBox->text(n) returns non-null for 0 <= n < newListbox->count(). This assumption is necessary because of the line edit in QComboBox.
virtual void QComboBox::setListBox ( QListBox ) [virtual]
virtual void QComboBox::setMaxCount ( int  ) [virtual]
void QComboBox::setMaxCount ( int  count) [virtual]
void QComboBox::setPalette ( const QPalette palette) [virtual]

Sets the palette for both the combobox button and the combobox popup list to palette.

Reimplementado de QWidget.

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

Reimplementado de QWidget.

void QComboBox::setSizeLimit ( int  lines) [virtual]
virtual void QComboBox::setSizeLimit ( int  ) [virtual]
void QComboBox::setValidator ( const QValidator v) [virtual]

Applies the validator v to the combobox so that only text which is valid according to v is accepted.

This function does nothing if the combobox is not editable.

Ver también:
validator() clearValidator() QValidator
virtual void QComboBox::setValidator ( const QValidator ) [virtual]
QSize QComboBox::sizeHint ( ) const [virtual]

This implementation caches the size hint to avoid resizing when the contents change dynamically. To invalidate the cached value call setFont().

Reimplementado de QWidget.

QSize QComboBox::sizeHint ( ) const [virtual]

Reimplementado de QWidget.

int QComboBox::sizeLimit ( ) const
int QComboBox::sizeLimit ( ) const
void QComboBox::styleChange ( QStyle ) [protected, virtual]

This virtual function is called when the style of the widgets changes. oldStyle is the previous GUI style; you can get the new style from style().

Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using update().

The default implementation updates the widget including its geometry.

Ver también:
QApplication::setStyle(), style(), update(), updateGeometry()

Reimplementado de QWidget.

void QComboBox::styleChange ( QStyle s) [protected, virtual]

Reimplementado de QWidget.

QString QComboBox::text ( int  index) const
QString QComboBox::text ( int  index) const

Returns the text item at position index, or QString::null if the item is not a string.

Ver también:
currentText()
void QComboBox::textChanged ( const QString ) [signal]
void QComboBox::textChanged ( const QString string) [signal]

This signal is used for editable comboboxes. It is emitted whenever the contents of the text entry field changes. string contains the new text.

void QComboBox::updateMask ( ) [protected, virtual]

This function can be reimplemented in a subclass to support transparent widgets. It should be called whenever a widget changes state in a way that means that the shape mask must be recalculated.

Ver también:
setAutoMask(), updateMask(), setMask(), clearMask()

Reimplementado de QWidget.

void QComboBox::updateMask ( ) [protected, virtual]

Reimplementado de QWidget.

const QValidator * QComboBox::validator ( ) const

Returns the validator which constrains editing for this combobox if there is one; otherwise returns 0.

Ver también:
setValidator() clearValidator() QValidator
const QValidator* QComboBox::validator ( ) const
void QComboBox::wheelEvent ( QWheelEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive wheel events for the widget.

If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.

The default implementation ignores the event.

Ver también:
QWheelEvent::ignore(), QWheelEvent::accept(), event(), QWheelEvent

Reimplementado de QWidget.

void QComboBox::wheelEvent ( QWheelEvent e) [protected, virtual]

Reimplementado de QWidget.


Documentación de propiedades

bool QComboBox::autoCompletion [read, write]

whether auto-completion is enabled

This property can only be set for editable comboboxes, for non-editable comboboxes it has no effect. It is FALSE by default.

bool QComboBox::autoResize [read, write]

whether auto resize is enabled

If this property is set to TRUE then the combobox will resize itself whenever its contents change. The default is FALSE.

int QComboBox::count [read]

the number of items in the combobox

int QComboBox::currentItem [read, write]

the index of the current item in the combobox

Note that the activated() and highlighted() signals are only emitted when the user changes the current item, not when it is changed programmatically.

QString QComboBox::currentText [read, write]

the text of the combobox's current item

bool QComboBox::duplicatesEnabled [read, write]

whether duplicates are allowed

If the combobox is editable and the user enters some text in the combobox's lineedit and presses Enter (and the insertionPolicy() is not NoInsertion), then what happens is this: If the text is not already in the list, the text is inserted. If the text is in the list and this property is TRUE (the default), the text is inserted. If the text is in the list and this property is FALSE, the text is not inserted; instead the item which has matching text becomes the current item.

This property only affects user-interaction. You can use insertItem() to insert duplicates if you wish regardless of this setting.

bool QComboBox::editable [read, write]

whether the combobox is editable

This property's default is FALSE. Note that the combobox will be cleared if this property is set to TRUE for a 1.x Motif style combobox. To avoid this, use setEditable() before inserting any items. Also note that the 1.x version of Motif didn't have any editable comboboxes, so the combobox will change it's appearance to a 2.0 style Motif combobox is it is set to be editable.

Policy QComboBox::insertionPolicy [read, write]

the position of the items inserted by the user

The default insertion policy is AtBottom. See Policy.

int QComboBox::maxCount [read, write]

the maximum number of items allowed in the combobox

int QComboBox::sizeLimit [read, write]

the maximum on-screen size of the combobox.

This property is ignored for both Motif 1.x style and non-editable comboboxes in Mac style. The default limit is ten lines. If the number of items in the combobox is or grows larger than lines, a scrollbar is added.


La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'