Doc: Improve the QCombobox Documentation
The purpose of this commit is to improve the QCombobox documentation. The following updates were made: - The Combobox image was udated with a better quality image. - The brief was updated to make it more understandable. - The detailed description was updated with subsection titles. - Full stops were added to the sentences that were missing them. Fixes: QTBUG-117748 Pick-to: 6.5 Change-Id: I417a720299ac0eb2be3f080f2fc0f76a27242423 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 48c6f7250a439092cb7ede31e0169e790c9b5cd8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a6a9ac8539
commit
524ce5bc3f
BIN
src/widgets/doc/images/collapsed_combobox.png
Normal file
BIN
src/widgets/doc/images/collapsed_combobox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
BIN
src/widgets/doc/images/expanded_combobox.png
Normal file
BIN
src/widgets/doc/images/expanded_combobox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -947,39 +947,34 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QComboBox
|
\class QComboBox
|
||||||
\brief The QComboBox widget is a combined button and popup list.
|
\brief The QComboBox widget combines a button with a dropdown list.
|
||||||
|
|
||||||
\ingroup basicwidgets
|
\ingroup basicwidgets
|
||||||
\inmodule QtWidgets
|
\inmodule QtWidgets
|
||||||
|
|
||||||
\image windows-combobox.png
|
\table
|
||||||
|
\row
|
||||||
|
\li \inlineimage collapsed_combobox.png
|
||||||
|
\caption Collapsed QCombobox
|
||||||
|
\li
|
||||||
|
\inlineimage expanded_combobox.png
|
||||||
|
\caption Expanded QCombobox
|
||||||
|
\endtable
|
||||||
|
|
||||||
A QComboBox provides a means of presenting a list of options to the user
|
\section1 Display Features
|
||||||
in a way that takes up the minimum amount of screen space.
|
A QComboBox is a compact way to present a list of options to the user.
|
||||||
|
|
||||||
A combobox is a selection widget that displays the current item,
|
A combobox is a selection widget that shows the current item,
|
||||||
and can pop up a list of selectable items. A combobox may be editable,
|
and pops up a list of selectable items when clicked. Comboboxes can
|
||||||
allowing the user to modify each item in the list.
|
contain pixmaps as well as strings if the insertItem() and setItemText()
|
||||||
|
functions are suitably overloaded.
|
||||||
|
|
||||||
Comboboxes can contain pixmaps as well as strings; the
|
\section1 Editing Features
|
||||||
insertItem() and setItemText() functions are suitably overloaded.
|
A combobox may be editable, allowing the user to modify each item in the
|
||||||
For editable comboboxes, the function clearEditText() is provided,
|
list. For editable comboboxes, the function clearEditText() is provided,
|
||||||
to clear the displayed string without changing the combobox's
|
to clear the displayed string without changing the combobox's
|
||||||
contents.
|
contents.
|
||||||
|
|
||||||
There are three signals emitted if the current item of a combobox
|
|
||||||
changes, currentIndexChanged(), currentTextChanged() and activated().
|
|
||||||
currentIndexChanged() and currentTextChanged() are always emitted
|
|
||||||
regardless if the change
|
|
||||||
was done programmatically or by user interaction, while
|
|
||||||
activated() is only emitted when the change is caused by user
|
|
||||||
interaction. The highlighted() signal is emitted when the user
|
|
||||||
highlights an item in the combobox popup list. All three signals
|
|
||||||
exist in two versions, one with a QString argument and one with an
|
|
||||||
\c int argument. If the user selects or highlights a pixmap, only
|
|
||||||
the \c int signals are emitted. Whenever the text of an editable
|
|
||||||
combobox is changed the editTextChanged() signal is emitted.
|
|
||||||
|
|
||||||
When the user enters a new string in an editable combobox, the
|
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
|
widget may or may not insert it, and it can insert it in several
|
||||||
locations. The default policy is \l InsertAtBottom but you can change
|
locations. The default policy is \l InsertAtBottom but you can change
|
||||||
@ -1002,17 +997,33 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
|
|||||||
setCompleter() and whether or not the user can add duplicates
|
setCompleter() and whether or not the user can add duplicates
|
||||||
is set with setDuplicatesEnabled().
|
is set with setDuplicatesEnabled().
|
||||||
|
|
||||||
QComboBox uses the \l{Model/View Programming}{model/view
|
\section1 Signals
|
||||||
framework} for its popup list and to store its items. By default
|
There are three signals emitted if the current item of a combobox
|
||||||
a QStandardItemModel stores the items and a QListView subclass
|
changes: currentIndexChanged(), currentTextChanged(), and activated().
|
||||||
displays the popuplist. You can access the model and view directly
|
currentIndexChanged() and currentTextChanged() are always emitted
|
||||||
(with model() and view()), but QComboBox also provides functions
|
regardless if the change
|
||||||
to set and get item data (e.g., setItemData() and itemText()). You
|
was done programmatically or by user interaction, while
|
||||||
can also set a new model and view (with setModel() and setView()).
|
activated() is only emitted when the change is caused by user
|
||||||
For the text and icon in the combobox label, the data in the model
|
interaction. The highlighted() signal is emitted when the user
|
||||||
that has the Qt::DisplayRole and Qt::DecorationRole is used. Note
|
highlights an item in the combobox popup list. All three signals
|
||||||
that you cannot alter the \l{QAbstractItemView::}{SelectionMode}
|
exist in two versions, one with a QString argument and one with an
|
||||||
of the view(), e.g., by using
|
\c int argument. If the user selects or highlights a pixmap, only
|
||||||
|
the \c int signals are emitted. Whenever the text of an editable
|
||||||
|
combobox is changed, the editTextChanged() signal is emitted.
|
||||||
|
|
||||||
|
\section1 Model/View Framework
|
||||||
|
|
||||||
|
QComboBox uses the \l{Model/View Programming}{model/view framework} for its
|
||||||
|
popup list and to store its items. By default a QStandardItemModel stores
|
||||||
|
the items and a QListView subclass displays the popuplist. You can access
|
||||||
|
the model and view directly (with model() and view()), but QComboBox also
|
||||||
|
provides functions to set and get item data, for example, setItemData() and
|
||||||
|
itemText(). You can also set a new model and view (with setModel()
|
||||||
|
and setView()). For the text and icon in the combobox label, the data in
|
||||||
|
the model that has the Qt::DisplayRole and Qt::DecorationRole is used.
|
||||||
|
|
||||||
|
\note You cannot alter the \l{QAbstractItemView::}{SelectionMode}
|
||||||
|
of the view(), for example, by using
|
||||||
\l{QAbstractItemView::}{setSelectionMode()}.
|
\l{QAbstractItemView::}{setSelectionMode()}.
|
||||||
|
|
||||||
\sa QLineEdit, QSpinBox, QRadioButton, QButtonGroup
|
\sa QLineEdit, QSpinBox, QRadioButton, QButtonGroup
|
||||||
@ -1459,7 +1470,7 @@ void QComboBox::setMaxVisibleItems(int maxItems)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::count
|
\property QComboBox::count
|
||||||
\brief the number of items in the combobox
|
\brief the number of items in the combobox.
|
||||||
|
|
||||||
By default, for an empty combo box, this property has a value of 0.
|
By default, for an empty combo box, this property has a value of 0.
|
||||||
*/
|
*/
|
||||||
@ -1471,7 +1482,7 @@ int QComboBox::count() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::maxCount
|
\property QComboBox::maxCount
|
||||||
\brief the maximum number of items allowed in the combobox
|
\brief the maximum number of items allowed in the combobox.
|
||||||
|
|
||||||
\note If you set the maximum number to be less then the current
|
\note If you set the maximum number to be less then the current
|
||||||
amount of items in the combobox, the extra items will be
|
amount of items in the combobox, the extra items will be
|
||||||
@ -1504,7 +1515,7 @@ int QComboBox::maxCount() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::duplicatesEnabled
|
\property QComboBox::duplicatesEnabled
|
||||||
\brief whether the user can enter duplicate items into the combobox
|
\brief whether the user can enter duplicate items into the combobox.
|
||||||
|
|
||||||
Note that it is always possible to programmatically insert duplicate items into the
|
Note that it is always possible to programmatically insert duplicate items into the
|
||||||
combobox.
|
combobox.
|
||||||
@ -1550,7 +1561,7 @@ int QComboBox::findData(const QVariant &data, int role, Qt::MatchFlags flags) co
|
|||||||
/*!
|
/*!
|
||||||
\property QComboBox::insertPolicy
|
\property QComboBox::insertPolicy
|
||||||
\brief the policy used to determine where user-inserted items should
|
\brief the policy used to determine where user-inserted items should
|
||||||
appear in the combobox
|
appear in the combobox.
|
||||||
|
|
||||||
The default value is \l InsertAtBottom, indicating that new items will appear
|
The default value is \l InsertAtBottom, indicating that new items will appear
|
||||||
at the bottom of the list of items.
|
at the bottom of the list of items.
|
||||||
@ -1573,7 +1584,7 @@ void QComboBox::setInsertPolicy(InsertPolicy policy)
|
|||||||
/*!
|
/*!
|
||||||
\property QComboBox::sizeAdjustPolicy
|
\property QComboBox::sizeAdjustPolicy
|
||||||
\brief the policy describing how the size of the combobox changes
|
\brief the policy describing how the size of the combobox changes
|
||||||
when the content changes
|
when the content changes.
|
||||||
|
|
||||||
The default value is \l AdjustToContentsOnFirstShow.
|
The default value is \l AdjustToContentsOnFirstShow.
|
||||||
|
|
||||||
@ -1664,7 +1675,7 @@ void QComboBox::setIconSize(const QSize &size)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::placeholderText
|
\property QComboBox::placeholderText
|
||||||
\brief Sets a \a placeholderText text shown when no valid index is set
|
\brief Sets a \a placeholderText text shown when no valid index is set.
|
||||||
|
|
||||||
The \a placeholderText will be shown when an invalid index is set. The
|
The \a placeholderText will be shown when an invalid index is set. The
|
||||||
text is not accessible in the dropdown list. When this function is called
|
text is not accessible in the dropdown list. When this function is called
|
||||||
@ -1703,7 +1714,7 @@ QString QComboBox::placeholderText() const
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::editable
|
\property QComboBox::editable
|
||||||
\brief whether the combo box can be edited by the user
|
\brief whether the combo box can be edited by the user.
|
||||||
|
|
||||||
By default, this property is \c false. The effect of editing depends
|
By default, this property is \c false. The effect of editing depends
|
||||||
on the insert policy.
|
on the insert policy.
|
||||||
@ -3482,7 +3493,7 @@ QVariant QComboBox::inputMethodQuery(Qt::InputMethodQuery query, const QVariant
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QComboBox::frame
|
\property QComboBox::frame
|
||||||
\brief whether the combo box draws itself with a frame
|
\brief whether the combo box draws itself with a frame.
|
||||||
|
|
||||||
|
|
||||||
If enabled (the default) the combo box draws itself inside a
|
If enabled (the default) the combo box draws itself inside a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user