qcombobox.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 561 行 · 第 1/3 页
HTML
561 行
duplicates is set with <a href="#setDuplicatesEnabled">setDuplicatesEnabled</a>().<p> <img src="qcombo1-m.png">(Motif 1, read-only)<br clear=all><img src="qcombo2-m.png">(Motif 2, read-write)<br clear=all><img src="qcombo3-m.png">(Motif 2, read-only)<br clear=all><img src="qcombo1-w.png">(Windows style)<p> <p>See also <a href="qlineedit.html">QLineEdit</a>, <a href="qlistbox.html">QListBox</a>, <a href="qspinbox.html">QSpinBox</a>, <a href="qradiobutton.html">QRadioButton</a>, <a href="qbuttongroup.html">QButtonGroup</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Combo Box</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Drop-Down List Box</a> and <a href="basic.html">Basic Widgets</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="Policy-enum"></a>QComboBox::Policy</h3> <p> This enum specifies what the QComboBox should do when a new string isentered by the user. The following policies are defined:<ul><li><tt>QComboBox::NoInsertion</tt> - the string will not be inserted into the combobox.<li><tt>QComboBox::AtTop</tt> - insert the string as the first item in the combobox.<li><tt>QComboBox::AtCurrent</tt> - replace the previously selected item with the stringthe user has entered.<li><tt>QComboBox::AtBottom</tt> - insert the string as the last item in thecombobox.<li><tt>QComboBox::AfterCurrent</tt> - insert the string after thepreviously selected item.<li><tt>QComboBox::BeforeCurrent</tt> - insert the string before thepreviously selected item.</ul><p> <a href="#activated">activated</a>() is always emitted when the string is entered.<p> If inserting the new string would cause the combobox to breach itscontent size limit, the item at the other end of the list is deleted.The definition of "other end" is implementation-dependent.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QComboBox"></a>QComboBox::QComboBox ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )</h3>Constructs a combobox widget with parent <em>parent</em> and name <em>name</em>.<p> 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.<h3 class=fn><a name="QComboBox-2"></a>QComboBox::QComboBox ( bool rw, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )</h3>Constructs a combobox with a maximum size and either Motif 2.0 orWindows look and feel.<p> The input field can be edited if <em>rw</em> is TRUE, otherwise the usermay only choose one of the items in the combobox.<p> The <em>parent</em> and <em>name</em> arguments are passed on to the <a href="qwidget.html">QWidget</a>constructor.<h3 class=fn><a name="~QComboBox"></a>QComboBox::~QComboBox ()</h3>Destroys the combobox.<h3 class=fn>void <a name="activated"></a>QComboBox::activated ( int index )<tt> [signal]</tt></h3> <p> This signal is emitted when a new item has been activated (selected).The <em>index</em> is the position of the item in the combobox.<p>Examples: <a href="fileiconview-example.html#x873">fileiconview/mainwindow.cpp</a>, <a href="helpviewer-example.html#x982">helpviewer/helpwindow.cpp</a>, <a href="lineedits-example.html#x100">lineedits/lineedits.cpp</a>, <a href="listboxcombo-example.html#x1125">listboxcombo/listboxcombo.cpp</a>, <a href="ftpclient-example.html#x650">network/ftpclient/ftpmainwindow.cpp</a> and <a href="qmag-example.html#x1625">qmag/qmag.cpp</a>.<h3 class=fn>void <a name="activated-2"></a>QComboBox::activated ( const <a href="qstring.html">QString</a> & string )<tt> [signal]</tt></h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> This signal is emitted when a new item has been activated(selected). <em>string</em> is the selected string.<p> You can also use the <a href="#activated">activated</a>(int) signal, but be aware that itsargument is meaningful only for selected strings, not for user enteredstrings.<h3 class=fn>bool <a name="autoCompletion"></a>QComboBox::autoCompletion () const</h3><p>Returns TRUE if auto-completion is enabled; otherwise returns FALSE.See the <a href="qcombobox.html#autoCompletion-prop">"autoCompletion"</a> property for details.<h3 class=fn>bool <a name="autoResize"></a>QComboBox::autoResize () const</h3><p>Returns TRUE if auto resize is enabled; otherwise returns FALSE.See the <a href="qcombobox.html#autoResize-prop">"autoResize"</a> property for details.<h3 class=fn>void <a name="changeItem"></a>QComboBox::changeItem ( const <a href="qstring.html">QString</a> & t, int index )</h3>Replaces the item at position <em>index</em> with the text <em>t</em>.<h3 class=fn>void <a name="changeItem-2"></a>QComboBox::changeItem ( const <a href="qpixmap.html">QPixmap</a> & im, int index )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Replaces the item at position <em>index</em> with the pixmap <em>im</em>, unlessthe combobox is editable.<p> <p>See also <a href="#insertItem">insertItem</a>().<h3 class=fn>void <a name="changeItem-3"></a>QComboBox::changeItem ( const <a href="qpixmap.html">QPixmap</a> & im, const <a href="qstring.html">QString</a> & t, int index )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Replaces the item at position <em>index</em> with the pixmap <em>im</em> and thetext <em>t</em>.<p> <p>See also <a href="#insertItem">insertItem</a>().<h3 class=fn>void <a name="clear"></a>QComboBox::clear ()<tt> [slot]</tt></h3>Removes all combobox items.<h3 class=fn>void <a name="clearEdit"></a>QComboBox::clearEdit ()<tt> [slot]</tt></h3> Clears the line edit without changing the combobox's contents.Does nothing if the combobox isn't editable.<p> This is particularly handy when using a combobox as a line editwith history. For example you can connect the combobox's <a href="#activated">activated</a>()signal to <a href="#clearEdit">clearEdit</a>() in order to present the user with a new, emptyline as soon as Return is pressed.<p> <p>See also <a href="#setEditText">setEditText</a>().<h3 class=fn>void <a name="clearValidator"></a>QComboBox::clearValidator ()<tt> [slot]</tt></h3> This slot is equivalent to <a href="#setValidator">setValidator</a>( 0 ). <h3 class=fn>int <a name="count"></a>QComboBox::count () const</h3><p>Returns the number of items in the combobox.See the <a href="qcombobox.html#count-prop">"count"</a> property for details.<h3 class=fn>int <a name="currentItem"></a>QComboBox::currentItem () const</h3><p>Returns the index of the current item in the combobox.See the <a href="qcombobox.html#currentItem-prop">"currentItem"</a> property for details.<h3 class=fn><a href="qstring.html">QString</a> <a name="currentText"></a>QComboBox::currentText () const</h3><p>Returns the text of the combobox's current item.See the <a href="qcombobox.html#currentText-prop">"currentText"</a> property for details.<h3 class=fn>bool <a name="duplicatesEnabled"></a>QComboBox::duplicatesEnabled () const</h3><p>Returns TRUE if duplicates are allowed; otherwise returns FALSE.See the <a href="qcombobox.html#duplicatesEnabled-prop">"duplicatesEnabled"</a> property for details.<h3 class=fn>bool <a name="editable"></a>QComboBox::editable () const</h3><p>Returns TRUE if the combobox is editable; otherwise returns FALSE.See the <a href="qcombobox.html#editable-prop">"editable"</a> property for details.<h3 class=fn>void <a name="highlighted"></a>QComboBox::highlighted ( int index )<tt> [signal]</tt></h3> <p> This signal is emitted when a new item has been set to current.The <em>index</em> is the position of the item in the combobox.<h3 class=fn>void <a name="highlighted-2"></a>QComboBox::highlighted ( const <a href="qstring.html">QString</a> & string )<tt> [signal]</tt></h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> This signal is emitted when a new item has been highlighted. <em>string</em> is the highlighted string.<p> You can also use <a href="#highlighted">highlighted</a>(int) signal.<h3 class=fn>void <a name="insertItem"></a>QComboBox::insertItem ( const <a href="qstring.html">QString</a> & t, int index = -1 )</h3>Inserts a text item with text <em>t</em>, at position <em>index</em>. The itemwill be appended if <em>index</em> is negative.<p>Examples: <a href="tutorial2-09.html#x2538">chart/optionsform.cpp</a>, <a href="fileiconview-example.html#x875">fileiconview/mainwindow.cpp</a>, <a href="helpviewer-example.html#x984">helpviewer/helpwindow.cpp</a>, <a href="lineedits-example.html#x101">lineedits/lineedits.cpp</a>, <a href="listboxcombo-example.html#x1126">listboxcombo/listboxcombo.cpp</a>, <a href="ftpclient-example.html#x652">network/ftpclient/ftpmainwindow.cpp</a> and <a href="tictac-example.html#x119">tictac/tictac.cpp</a>.<h3 class=fn>void <a name="insertItem-2"></a>QComboBox::insertItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, int index = -1 )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Inserts a <em>pixmap</em> item at position <em>index</em>. The item will beappended if <em>index</em> is negative.<h3 class=fn>void <a name="insertItem-3"></a>QComboBox::insertItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, const <a href="qstring.html">QString</a> & text, int index = -1 )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Inserts a <em>pixmap</em> item with additional text <em>text</em> at position <em>index</em>. The item will be appended if <em>index</em> is negative.<h3 class=fn>void <a name="insertStrList"></a>QComboBox::insertStrList ( const char ** strings, int numStrings = -1, int index = -1 )</h3>Inserts the array of char * <em>strings</em> at position <em>index</em> in thecombobox.<p> The <em>numStrings</em> argument is the number of strings.If <em>numStrings</em> is -1 (default), the <em>strings</em> array must beterminated with 0.<p> Example:<pre> static const char* items[] = { "red", "green", "blue", 0 }; combo->insertStrList( items ); </pre> <p>Example: <a href="qmag-example.html#x1626">qmag/qmag.cpp</a>.<h3 class=fn>void <a name="insertStrList-2"></a>QComboBox::insertStrList ( const <a href="qstrlist.html">QStrList</a> & list, int index = -1 )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Inserts the <em>list</em> of strings at position <em>index</em> in the combobox.<p> This is only for compatibility, as it does not support Unicodestrings. See <a href="#insertStringList">insertStringList</a>().<h3 class=fn>void <a name="insertStrList-3"></a>QComboBox::insertStrList ( const <a href="qstrlist.html">QStrList</a> * list, int index = -1 )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Inserts the <em>list</em> of strings at position <em>index</em> in the combobox.<p> This is only for compatibility, as it does not support Unicodestrings. See <a href="#insertStringList">insertStringList</a>().<h3 class=fn>void <a name="insertStringList"></a>QComboBox::insertStringList ( const <a href="qstringlist.html">QStringList</a> & list, int index = -1 )</h3>Inserts the <em>list</em> of strings at position <em>index</em> in the combobox.<h3 class=fn><a href="qcombobox.html#Policy-enum">Policy</a> <a name="insertionPolicy"></a>QComboBox::insertionPolicy () const</h3><p>Returns the position of the items inserted by the user.See the <a href="qcombobox.html#insertionPolicy-prop">"insertionPolicy"</a> property for details.<h3 class=fn><a href="qlineedit.html">QLineEdit</a> * <a name="lineEdit"></a>QComboBox::lineEdit () const</h3>Returns the line editor, or 0 if there is no line editor.<p> Only editable listboxes have a line editor.<h3 class=fn><a href="qlistbox.html">QListBox</a> * <a name="listBox"></a>QComboBox::listBox () const</h3> Returns the current list box, or 0 if there is no list box.(QComboBox can use <a href="qpopupmenu.html">QPopupMenu</a> instead of <a href="qlistbox.html">QListBox</a>.)Provided to match <a href="#setListBox">setListBox</a>().
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?