📄 qcombobox.3qt
字号:
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 ()"Destructs 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 is 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"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPReturns 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, const QString & t, int index )"Replaces the item at position \fIindex\fR with a pixmap plus text..PPSee also insertItem()..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::duplicatesEnabled () const"Returns TRUE if the same text can be inserted multiple times into the list of the combobox, else FALSE..PPSee also setDuplicatesEnabled();..SH "bool QComboBox::editable () const"Returns whether the combobox is editable or not..PPSee also setEditable()..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 * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..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, const QString & text, int index=-1 )"Inserts a pixmap item with additional text \fItext\fR at position \fIindex.\fR The item will be appended if \fIindex\fR is negative..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..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 "QComboBox::Policy QComboBox::insertionPolicy() const"Returns the current insertion policy of the combo box..PPSee also setInsertionPolicy()..SH "void QComboBox::keyPressEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QLineEdit* QComboBox::lineEdit () const"Returns the line editor, or 0 if there is no line editor currently..PPOnly editable listboxes have a line editor..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"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QComboBox::mouseMoveEvent ( QMouseEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QComboBox::mousePressEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QComboBox::mouseReleaseEvent ( QMouseEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QComboBox::paintEvent ( QPaintEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..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 * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..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..PPNote: This will only work on editable combo boxes, so make the combo box editable before you call this function or it will not work..PPSee also autoCompletion() and setEditText()..SH "void QComboBox::setAutoResize ( bool enable ) \fC[virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPEnables 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::setDuplicatesEnabled ( bool enable )"If the combobox is editable and the user enters some text in the lineedit of the combobox and presses return (and the insertionPolicy() is different from \fCNoInsertion),\fR the entered text is inserted into the list of this combobox. Now, if you set \fIenable\fR to TRUE here, this new text is always inserted, else it's only inserted if it doesn't already exist in the list. If you set \fIenable\fR to FALSE and the text exists already in the list, the item which contains the same text like which should be inserted, this item gets the new current item..PPThis setting only applies when the user want's to insert a text with pressing the return key. It does \fInot\fR affect methods like insertItem() and similar..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 clearEdit() and insertItem()..SH "void QComboBox::setEditable ( bool y )"Make the input field editable, if \fIy\fR is TRUE. Otherwise the user may only choose one of the items in the combo box..PPSee also editable()..SH "void QComboBox::setEnabled ( bool enable ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..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 )"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 insertionPolicy()..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 side 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"Reimplemented for internal reasons; the API is not affected..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"Reimplemented for internal reasons; the API is not affected..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 "void QComboBox::updateMask () \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..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://doc.trolltech.com/qcombobox.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qcombobox.3qt) and the Qtversion (2.3.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -