📄 qcombobox.3qt
字号:
See also: QLineEdit, QListBox, QSpinBox, QRadioButton, QButtonGroup, GUI Design Handbook: Combo Box, and GUI Design Handbook: Drop-Down List Box..PPExamples:.(lqmag/qmag.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QComboBox::QComboBox ( QWidget * parent=0, const char * name=0 )"Constructs a combo box widget with a parent and a name..PPThis constructor creates a popup menu if the program uses Motif look and feel; this is compatible with Motif 1.x..SH "QComboBox::QComboBox ( bool rw, QWidget * parent=0, const char * name=0 )"Constructs a combo box with a maximum size and either Motif 2.0 or Windows look and feel..PPThe input field can be edited if \fIrw\fR is TRUE, otherwise the user may only choose one of the items in the combo box..SH "QComboBox::~QComboBox ()"Destroys the combo box..SH "void QComboBox::activated ( const QString & string ) \fC[signal]\fR"This signal is emitted when a new item has been activated (selected). \fIstring\fR is the activated string..PPYou can also use activated(int) signal, but be aware that its argument meaningful only for selected strings, not for typed strings..SH "void QComboBox::activated ( int index ) \fC[signal]\fR"This signal is emitted when a new item has been activated (selected). The \fIindex\fR is the position of the item in the popup list..SH "bool QComboBox::autoCompletion () const"Returns TRUE if this combo box is in auto-completion mode..PPSee also: setAutoCompletion()..SH "bool QComboBox::autoResize () const"Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is disabled..PPAuto-resizing is disabled by default..PPSee also: setAutoResize()..SH "void QComboBox::changeItem ( const QPixmap & im, int index )"Replaces the item at position \fIindex\fR with a pixmap, unless the combo box is writable..PPSee also: insertItem()..SH "void QComboBox::changeItem ( const QString & t, int index )"Replaces the item at position \fIindex\fR with a text..SH "void QComboBox::clear ()"Removes all combo box items..SH "void QComboBox::clearEdit () \fC[slot]\fR"Clears the line edit without changing the combo's contents. Does nothing if the combo isn't editable..PPThis is particularly handy when using a combo box as a line edit with history. For example you can connect the combo's activated() signal to clearEdit() in order to present the user with a new, empty line as soon as return is pressed..PPSee also: setEditText()..SH "void QComboBox::clearValidator () \fC[slot]\fR"This slot is equivalent to setValidator( 0 )..SH "int QComboBox::count () const"Returns the number of items in the combo box..SH "int QComboBox::currentItem () const"Returns the index of the current combo box item..PPSee also: setCurrentItem()..SH "QString QComboBox::currentText () const"Returns the text item being edited, or the current text item if the combo box is not editable..PPSee also: text()..SH "bool QComboBox::eventFilter ( QObject * object, QEvent * event ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QObject..SH "void QComboBox::focusInEvent ( QFocusEvent * ) \fC[virtual protected]\fR"Handles focus in events..PPReimplemented from QWidget..SH "void QComboBox::highlighted ( const QString & string ) \fC[signal]\fR"This signal is emitted when a new item has been highlighted. \fIstring\fR is the highlighted string..PPYou can also use highlighted(int) signal..SH "void QComboBox::highlighted ( int index ) \fC[signal]\fR"This signal is emitted when a new item has been set to current. The \fIindex\fR is the position of the item in the popup list..SH "void QComboBox::insertItem ( const QPixmap & pixmap, int index=-1 )"Inserts a pixmap item at position \fIindex.\fR The item will be appended if \fIindex\fR is negative..PPIf the combo box is writable, the pixmap is not inserted..SH "void QComboBox::insertItem ( const QString & t, int index=-1 )"Inserts a text item at position \fIindex.\fR The item will be appended if \fIindex\fR is negative..SH "void QComboBox::insertStrList ( const QStrList * list, int index=-1 )"Inserts the list of strings at the index \fIindex\fR in the combo box..PPThis is only for compatibility, as it does not support Unicode strings. See insertStringList()..PPExamples:.(lqmag/qmag.cpp.)l.SH "void QComboBox::insertStrList ( const char ** strings, int numStrings=-1, int index=-1 )"Inserts the array of ASCII strings at the index \fIindex\fR in the combo box..PPThe \fInumStrings\fR argument is the number of strings. If \fInumStrings\fR is -1 (default), the \fIstrs\fR array must be terminated with 0..PPExample:.PP.nf.br static const char* items[] = { "red", "green", "blue", 0 };.br combo->insertStrList( items );.fi.SH "void QComboBox::insertStrList ( const QStrList & list, int index=-1 )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QComboBox::insertStringList ( const QStringList & list, int index=-1 )"Inserts the list of strings at the index \fIindex\fR in the combo box..SH "void QComboBox::keyPressEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"Handles key press events for the combo box..PPIn Motif style, up and down change the selected item and both enter and return pops up the list. In Windows style, all four arrow keys change the selected item, and Space pops up the list..PPReimplemented from QWidget..SH "QListBox * QComboBox::listBox () const"Returns the current list box, or 0 if there is no list box currently. (QComboBox can use QPopupMenu instead of QListBox.) Provided to match setListBox()..PPSee also: setListBox()..SH "int QComboBox::maxCount () const"Returns the current maximum size of the combo box. By default, there is no limit, so this function returns INT_MAX..PPSee also: setMaxCount() and count()..SH "void QComboBox::mouseDoubleClickEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Handles mouse double click events for the combo box..PPReimplemented from QWidget..SH "void QComboBox::mouseMoveEvent ( QMouseEvent * ) \fC[virtual protected]\fR"Handles mouse move events for the combo box..PPReimplemented from QWidget..SH "void QComboBox::mousePressEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Handles mouse press events for the combo box..PPReimplemented from QWidget..SH "void QComboBox::mouseReleaseEvent ( QMouseEvent * ) \fC[virtual protected]\fR"Handles mouse release events for the combo box..PPReimplemented from QWidget..SH "void QComboBox::paintEvent ( QPaintEvent * ) \fC[virtual protected]\fR"Handles paint events for the combo box..PPReimplemented from QWidget..SH "const QPixmap * QComboBox::pixmap ( int index ) const"Returns the pixmap item at a given index, or 0 if the item is not a pixmap..SH "void QComboBox::popup () \fC[protected]\fR"Popups the combo box popup list..PPIf the list is empty, no selections appear..SH "void QComboBox::removeItem ( int index )"Removes the item at position \fIindex.\fR.SH "void QComboBox::resizeEvent ( QResizeEvent * ) \fC[virtual protected]\fR"Handles resize events for the combo box..PPReimplemented from QWidget..SH "void QComboBox::setAutoCompletion ( bool enable ) \fC[virtual]\fR"Sets this combo box to offer auto-completion while the user is editing if \fIenable\fR is TRUE, or not to offer auto-completion of \fIenable\fR is FALSE (the default)..PPThe combo box uses the list of items as candidates for completion..PPSee also: autoCompletion() and setEditText()..SH "void QComboBox::setAutoResize ( bool enable ) \fC[virtual]\fR"Enables auto-resizing if \fIenable\fR is TRUE, or disables it if \fIenable\fR is FALSE..PPWhen auto-resizing is enabled, the combo box button will resize itself whenever the current combo box item change..PPSee also: autoResize() and adjustSize()..SH "void QComboBox::setBackgroundColor ( const QColor & color ) \fC[virtual]\fR"Reimplements QWidget::setBackgroundColor()..PPSets the background color for both the combo box button and the combo box popup list..SH "void QComboBox::setCurrentItem ( int index ) \fC[virtual]\fR"Sets the current combo box item. This is the item to be displayed on the combo box button..PPSee also: currentItem()..PPExamples:.(lqmag/qmag.cpp.)l.SH "void QComboBox::setEditText ( const QString & newText ) \fC[virtual slot]\fR"Sets the text in the embedded line edit to \fInewText\fR without changing the combo's contents. Does nothing if the combo isn't editable..PPThis is useful e.g. for providing a good starting point for the user's editing and entering the change in the combo only when the user presses enter..PPSee also: clearEditText() and insertItem()..SH "void QComboBox::setEnabled ( bool enable ) \fC[virtual]\fR"Reimplemented for internal purposes..SH "void QComboBox::setFont ( const QFont & font ) \fC[virtual]\fR"Reimplements QWidget::setFont()..PPSets the font for both the combo box button and the combo box popup list..SH "void QComboBox::setInsertionPolicy ( Policy policy ) \fC[virtual]\fR"Sets the insertion policy of the combo box to \fIpolicy.\fR.PPThe insertion policy governs where items typed in by the user are inserted in the list. The possible values are .TP\fCNoInsertion:\fR Strings typed by the user aren't inserted anywhere .TP\fCAtTop:\fR Strings typed by the user are inserted above the top item in the list .TPAtCurrent: Strings typed by the user replace the last selected item .TPAtBottom: Strings typed by the user are inserted at the bottom of the list. .PPThe default insertion policy is \fCAtBottom.\fR.PPSee also: policy()..SH "void QComboBox::setListBox ( QListBox * newListBox ) \fC[virtual]\fR"Sets the combo box to use \fInewListBox\fR instead of the current list box or popup. As a site effect, clears the combo box of its current contents..PP\fBWarning:\fR 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..SH "void QComboBox::setMaxCount ( int count ) \fC[virtual]\fR"Sets the maximum number of items the combo box can hold to \fIcount.\fR.PPIf \fIcount\fR is smaller than the current number of items, the list is truncated at the end. There is no limit by default..PPSee also: maxCount() and count()..SH "void QComboBox::setPalette ( const QPalette & palette ) \fC[virtual]\fR"Reimplements QWidget::setPalette()..PPSets the palette for both the combo box button and the combo box popup list..SH "void QComboBox::setSizeLimit ( int lines ) \fC[virtual]\fR"Sets the maximum on-screen size of the combo box to \fIlines.\fR This is disregarded in Motif 1.x style. The default limit is ten lines..PPIf the number of items in the combo box is/grows larger than \fClines,\fR a list box is added..PPSee also: sizeLimit(), count() and setMaxCount()..SH "void QComboBox::setValidator ( const QValidator * v ) \fC[virtual]\fR"Sets this combo box to be editable only as allowed by \fIv.\fR.PPThis function does nothing if the combo is not editable..PPSee also: validator(), clearValidator() and QValidator..SH "QSize QComboBox::sizeHint () const \fC[virtual]\fR"Returns a size which fits the contents of the combo box button..PPReimplemented from QWidget..SH "int QComboBox::sizeLimit () const"Returns the current maximum on-screen size of the combo box. The default is ten lines..PPSee also: setSizeLimit(), count() and maxCount()..SH "QSizePolicy QComboBox::sizePolicy () const \fC[virtual]\fR"Specifies that this widget may stretch horizontally, but is fixed vertically..SH "void QComboBox::styleChange ( QStyle & s ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QString QComboBox::text ( int index ) const"Returns the text item at a given index, or null string if the item is not a string..PPSee also: currentText()..SH "void QComboBox::textChanged ( const QString & string ) \fC[signal]\fR"This signal is useful for editable comboboxes. It is emitted whenever the contents of the text entry field changes..SH "const QValidator * QComboBox::validator () const"Returns the validator which constrains editing for this combo box if there is any, or else 0..PPSee also: setValidator(), clearValidator() and QValidator..SH "SEE ALSO".BR http://www.troll.no/qt/qcombobox.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -