📄 qcombobox.3qt
字号:
.TP\fCQComboBox::AfterCurrent\fR - insert the string after the previously selected item..TP\fCQComboBox::BeforeCurrent\fR - insert the string before the previously selected item..PPactivated() is always emitted when the string is entered..PPIf 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..SH MEMBER FUNCTION DOCUMENTATION.SH "QComboBox::QComboBox ( QWidget * parent = 0, const char * name = 0 )"Constructs a combobox widget with parent \fIparent\fR called \fIname\fR..PPThis constructor creates a popup list if the program uses Motif (or Aqua) look and feel; this is compatible with Motif 1.x and Aqua..SH "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..PPThe input field can be edited if \fIrw\fR is TRUE, otherwise the user may only choose one of the items in the combobox..PPThe \fIparent\fR and \fIname\fR arguments are passed on to the QWidget constructor..SH "QComboBox::~QComboBox ()"Destroys the combobox..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 combobox..PPExamples:.)l fileiconview/mainwindow.cpp, helpviewer/helpwindow.cpp, lineedits/lineedits.cpp, listboxcombo/listboxcombo.cpp, and qmag/qmag.cpp..SH "void QComboBox::activated ( const QString & string )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted when a new item has been activated (selected). \fIstring\fR is the selected string..PPYou can also use the activated(int) signal, but be aware that its argument is meaningful only for selected strings, not for user entered strings..SH "bool QComboBox::autoCompletion () const"Returns TRUE if auto-completion is enabled; otherwise returns FALSE. See the "autoCompletion" property for details..SH "bool QComboBox::autoResize () const"Returns TRUE if auto resize is enabled; otherwise returns FALSE. See the "autoResize" property for details..SH "void QComboBox::changeItem ( const QString & t, int index )"Replaces the item at position \fIindex\fR with the text \fIt\fR..SH "void QComboBox::changeItem ( const QPixmap & im, int index )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces the item at position \fIindex\fR with the pixmap \fIim\fR, unless the combobox is editable..PPSee also insertItem()..SH "void QComboBox::changeItem ( const QPixmap & im, const QString & t, int index )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces the item at position \fIindex\fR with the pixmap \fIim\fR and the text \fIt\fR..PPSee also insertItem()..SH "void QComboBox::clear ()\fC [slot]\fR"Removes all combobox items..SH "void QComboBox::clearEdit ()\fC [slot]\fR"Clears the line edit without changing the combobox's contents. Does nothing if the combobox isn't editable..PPThis 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..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 combobox. See the "count" property for details..SH "int QComboBox::currentItem () const"Returns the index of the current item in the combobox. See the "currentItem" property for details..SH "QString QComboBox::currentText () const"Returns the text of the combobox's current item. See the "currentText" property for details..SH "bool QComboBox::duplicatesEnabled () const"Returns TRUE if duplicates are allowed; otherwise returns FALSE. See the "duplicatesEnabled" property for details..SH "bool QComboBox::editable () const"Returns TRUE if the combobox is editable; otherwise returns FALSE. See the "editable" property for details..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 combobox..SH "void QComboBox::highlighted ( const QString & string )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted when a new item has been highlighted. \fIstring\fR is the highlighted string..PPYou can also use the highlighted(int) signal..SH "void QComboBox::insertItem ( const QString & t, int index = -1 )"Inserts a text item with text \fIt\fR, at position \fIindex\fR. The item will be appended if \fIindex\fR is negative..PPExamples:.)l chart/optionsform.cpp, chart/setdataform.cpp, fileiconview/mainwindow.cpp, helpviewer/helpwindow.cpp, lineedits/lineedits.cpp, listboxcombo/listboxcombo.cpp, and tictac/tictac.cpp..SH "void QComboBox::insertItem ( const QPixmap & pixmap, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a \fIpixmap\fR item at position \fIindex\fR. The item will be appended if \fIindex\fR is negative..SH "void QComboBox::insertItem ( const QPixmap & pixmap, const QString & text, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a \fIpixmap\fR item with additional text \fItext\fR at position \fIindex\fR. The item will be appended if \fIindex\fR is negative..SH "void QComboBox::insertStrList ( const char ** strings, int numStrings = -1, int index = -1 )"Inserts the array of char * \fIstrings\fR at position \fIindex\fR in the combobox..PPThe \fInumStrings\fR argument is the number of strings. If \fInumStrings\fR is -1 (default), the \fIstrings\fR array must be terminated with 0..PPExample:.PP.nf.br static const char* items[] = { "red", "green", "blue", 0 };.br combo->insertStrList( items );.br.fi.PPSee also insertStringList()..PPExample: qmag/qmag.cpp..SH "void QComboBox::insertStrList ( const QStrList & list, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts the \fIlist\fR of strings at position \fIindex\fR in the combobox..PPThis is only for compatibility since it does not support Unicode strings. See insertStringList()..SH "void QComboBox::insertStrList ( const QStrList * list, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts the \fIlist\fR of strings at position \fIindex\fR in the combobox..PPThis is only for compatibility since it does not support Unicode strings. See insertStringList()..SH "void QComboBox::insertStringList ( const QStringList & list, int index = -1 )"Inserts the \fIlist\fR of strings at position \fIindex\fR in the combobox..SH "Policy QComboBox::insertionPolicy () const"Returns the position of the items inserted by the user. See the "insertionPolicy" property for details..SH "QLineEdit * QComboBox::lineEdit () const"Returns the line edit, or 0 if there is no line edit..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. (QComboBox can use QPopupMenu instead of QListBox.) Provided to match setListBox()..PPSee also setListBox()..PPExample: listboxcombo/listboxcombo.cpp..SH "int QComboBox::maxCount () const"Returns the maximum number of items allowed in the combobox. See the "maxCount" property for details..SH "const QPixmap * QComboBox::pixmap ( int index ) const"Returns the pixmap item at position \fIindex\fR, or 0 if the item is not a pixmap..SH "void QComboBox::popup ()\fC [virtual]\fR"Pops up the combobox popup list..PPIf the list is empty, no items appear..SH "void QComboBox::removeItem ( int index )"Removes the item at position \fIindex\fR..SH "void QComboBox::setAutoCompletion ( bool )\fC [virtual]\fR"Sets whether auto-completion is enabled. See the "autoCompletion" property for details..SH "void QComboBox::setAutoResize ( bool )\fC [virtual]\fR"Sets whether auto resize is enabled. See the "autoResize" property for details..SH "void QComboBox::setCurrentItem ( int index )\fC [virtual]\fR"Sets the index of the current item in the combobox to \fIindex\fR. See the "currentItem" property for details..SH "void QComboBox::setCurrentText ( const QString & )\fC [virtual]\fR"Sets the text of the combobox's current item. See the "currentText" property for details..SH "void QComboBox::setDuplicatesEnabled ( bool enable )"Sets whether duplicates are allowed to \fIenable\fR. See the "duplicatesEnabled" property for details..SH "void QComboBox::setEditText ( const QString & newText )\fC [virtual slot]\fR"Sets the text in the line edit to \fInewText\fR without changing the combobox's contents. Does nothing if the combobox 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 combobox only when the user presses Enter..PPSee also clearEdit() and insertItem()..SH "void QComboBox::setEditable ( bool )"Sets whether the combobox is editable. See the "editable" property for details..SH "void QComboBox::setFont ( const QFont & font )\fC [virtual]\fR"Sets the font for both the combobox button and the combobox popup list to \fIfont\fR..PPReimplemented from QWidget..SH "void QComboBox::setInsertionPolicy ( Policy policy )\fC [virtual]\fR"Sets the position of the items inserted by the user to \fIpolicy\fR. See the "insertionPolicy" property for details..SH "void QComboBox::setLineEdit ( QLineEdit * edit )\fC [virtual]\fR"Sets the line edit to use \fIedit\fR instead of the current line edit..SH "void QComboBox::setListBox ( QListBox * newListBox )\fC [virtual]\fR"Sets the combobox to use \fInewListBox\fR instead of the current list box or popup. As a side effect, it clears the combobox 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 )\fC [virtual]\fR"Sets the maximum number of items allowed in the combobox. See the "maxCount" property for details..SH "void QComboBox::setPalette ( const QPalette & palette )\fC [virtual]\fR"Sets the palette for both the combobox button and the combobox popup list to \fIpalette\fR..PPReimplemented from QWidget..SH "void QComboBox::setSizeLimit ( int )\fC [virtual]\fR"Sets the maximum on-screen size of the combobox. See the "sizeLimit" property for details..SH "void QComboBox::setValidator ( const QValidator * v )\fC [virtual]\fR"Applies the validator \fIv\fR to the combobox so that only text which is valid according to \fIv\fR is accepted..PPThis function does nothing if the combobox is not editable..PPSee also validator(), clearValidator(), and QValidator..SH "int QComboBox::sizeLimit () const"Returns the maximum on-screen size of the combobox. See the "sizeLimit" property for details..SH "QString QComboBox::text ( int index ) const"Returns the text item at position \fIindex\fR, or QString::null if the item is not a string..PPSee also currentText..PPExamples:.)l fileiconview/mainwindow.cpp and helpviewer/helpwindow.cpp..SH "void QComboBox::textChanged ( const QString & string )\fC [signal]\fR"This signal is used for editable comboboxes. It is emitted whenever the contents of the text entry field changes. \fIstring\fR contains the new text..SH "const QValidator * QComboBox::validator () const"Returns the validator which constrains editing for this combobox if there is one; otherwise returns 0..PPSee also setValidator(), clearValidator(), and QValidator..SS "Property Documentation".SH "bool autoCompletion"This property holds whether auto-completion is enabled..PPThis property can only be set for editable comboboxes, for non-editable comboboxes it has no effect. It is FALSE by default..PPSet this property's value with setAutoCompletion() and get this property's value with autoCompletion()..SH "bool autoMask"This property holds whether the combobox is automatically masked..PPSee also QWidget::autoMask..SH "bool autoResize"This property holds whether auto resize is enabled..PP\fBThis property is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPIf this property is set to TRUE then the combobox will resize itself whenever its contents change. The default is FALSE..PPSet this property's value with setAutoResize() and get this property's value with autoResize()..SH "int count"This property holds the number of items in the combobox..PPGet this property's value with count()..SH "int currentItem"This property holds the index of the current item in the combobox..PPSet this property's value with setCurrentItem() and get this property's value with currentItem()..SH "QString currentText"This property holds the text of the combobox's current item..PPSet this property's value with setCurrentText() and get this property's value with currentText()..SH "bool duplicatesEnabled"This property holds whether duplicates are allowed..PPIf 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:.TPIf the text is not already in the list, the text is inserted..TPIf the text is in the list and this property is TRUE (the default), the text is inserted..TPIf the text is in the list and this property is FALSE, the text is \fInot\fR inserted; instead the item which has matching text becomes the current item..PPThis property only affects user-interaction. You can use insertItem() to insert duplicates if you wish regardless of this setting..PPSet this property's value with setDuplicatesEnabled() and get this property's value with duplicatesEnabled()..SH "bool editable"This property holds whether the combobox is editable..PPThis 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..PPSet this property's value with setEditable() and get this property's value with editable()..SH "Policy insertionPolicy"This property holds the position of the items inserted by the user..PPThe default insertion policy is AtBottom. See Policy..PPSet this property's value with setInsertionPolicy() and get this property's value with insertionPolicy()..SH "int maxCount"This property holds the maximum number of items allowed in the combobox..PPSet this property's value with setMaxCount() and get this property's value with maxCount()..SH "int sizeLimit"This property holds the maximum on-screen size of the combobox..PPThis is disregarded in Motif 1.x 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..PPSet this property's value with setSizeLimit() and get this property's value with sizeLimit()..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 help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qcombobox.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -