CopperSpice API
1.9.2
|
The QListWidgetItem class provides an item for use with the QListWidget item view class. More...
Public Types | |
enum | ItemType |
Public Methods | |
QListWidgetItem (const QIcon &icon, const QString &text, QListWidget *view=nullptr, int type=Type) | |
QListWidgetItem (const QListWidgetItem &other) | |
QListWidgetItem (const QString &text, QListWidget *view=nullptr, int type=Type) | |
QListWidgetItem (QListWidget *view=nullptr, int type=Type) | |
virtual | ~QListWidgetItem () |
QBrush | background () const |
QColor | backgroundColor () const |
Qt::CheckState | checkState () const |
virtual QListWidgetItem * | clone () const |
virtual QVariant | data (int role) const |
Qt::ItemFlags | flags () const |
QFont | font () const |
QBrush | foreground () const |
QIcon | icon () const |
bool | isHidden () const |
bool | isSelected () const |
QListWidget * | listWidget () const |
virtual bool | operator< (const QListWidgetItem &other) const |
QListWidgetItem & | operator= (const QListWidgetItem &other) |
virtual void | read (QDataStream &in) |
void | setBackground (const QBrush &brush) |
virtual void | setBackgroundColor (const QColor &color) |
void | setCheckState (Qt::CheckState state) |
virtual void | setData (int role, const QVariant &value) |
void | setFlags (Qt::ItemFlags flags) |
void | setFont (const QFont &font) |
void | setForeground (const QBrush &brush) |
void | setHidden (bool hide) |
void | setIcon (const QIcon &icon) |
void | setSelected (bool select) |
void | setSizeHint (const QSize &size) |
void | setStatusTip (const QString &statusTip) |
void | setText (const QString &text) |
void | setTextAlignment (int alignment) |
void | setTextColor (const QColor &color) |
void | setToolTip (const QString &toolTip) |
void | setWhatsThis (const QString &whatsThis) |
QSize | sizeHint () const |
QString | statusTip () const |
QString | text () const |
int | textAlignment () const |
QColor | textColor () const |
QString | toolTip () const |
int | type () const |
QString | whatsThis () const |
virtual void | write (QDataStream &out) const |
Friends | |
class | QListWidget |
Related Functions | |
These are not member functions | |
QDataStream & | operator<< (QDataStream &stream, const QListWidgetItem &item) |
QDataStream & | operator>> (QDataStream &stream, QListWidgetItem &item) |
The QListWidgetItem class provides an item for use with the QListWidget item view class. This class represents a single item in a QListWidget. Each item can hold several pieces of information, and will display them appropriately. The item view classes use a classic item-based interface rather than a pure model/view approach. For a more flexible list view widget, consider using the QListView class with a standard model.
List items can be inserted automatically into a list, when they are constructed, by specifying the list widget:
Alternatively, list items can also be created without a parent widget, and later inserted into a list using QListWidget::insertItem().
List items are typically used to display text() and an icon(). These are set with the setText() and setIcon() methods. The appearance of the text can be customized with setFont(), setForeground(), and setBackground(). Text in list items can be aligned using the setTextAlignment(). Tooltips, status tips and "What's This?" help can be added to list items with setToolTip(), setStatusTip(), and setWhatsThis().
By default, items are enabled, selectable, checkable, and can be the source of drag and drop operations.
The flags for each list items can be changed by calling setFlags(). Checkable items can be checked, unchecked and partially checked with setCheckState(). The corresponding checkState() indicates the current check state for the list item.
The isHidden() method is used to determine whether the item is hidden. To hide a list item call setHidden().
To add custom values for QListWidgetItem::ItemType, inherit from QListWidgetItem. Ensure your new class calls the base class constructor with a new type value equal to or greater than QListWidgetItem::UserType.
This enum describes the types which are used to describe list widget items. You can define new user types in QListWidgetItem subclasses to ensure that custom items are treated specially.
Constant | Value | Description |
---|---|---|
QListWidgetItem::Type | 0 | Default type for list widget items |
QListWidgetItem::UserType | 1000 | Custom types should be greater than this enum value |
|
explicit |
Constructs an empty list widget item of the specified type with the given view. If view is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<'
operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget::insertItem() instead.
|
explicit |
Constructs an empty list widget item of the specified type with the given text and view. If the view is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<'
operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget::insertItem() instead.
|
explicit |
Constructs an empty list widget item of the specified type with the given icon, text and view. If the view is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().
This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<'
operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget::insertItem() instead.
QListWidgetItem::QListWidgetItem | ( | const QListWidgetItem & | other | ) |
Constructs a copy of other. Note that type() and listWidget() are not copied. This method is useful when reimplementing clone().
|
virtual |
Destroys the list item.
|
inline |
Returns the brush used to display the list item's background.
|
inlinedeprecated |
|
inline |
Returns the checked state of this list item. Refer to Qt::CheckState.
|
virtual |
Creates a copy of the current QListWidgetItem.
|
virtual |
Returns the item's data for a given role. Reimplement this method if you need extra roles or special behavior for certain roles.
|
inline |
Returns the item flags for this list item. Refer to Qt::ItemFlags.
|
inline |
Returns the font used to display the text for this list item.
|
inline |
Returns the brush used to display the foreground for this list item.
|
inline |
Returns the list item's icon.
|
inline |
Returns true if this list item is hidden, otherwise returns false. You must add this list item to the QListWidget before calling this method.
|
inline |
Returns true if this list item is selected, otherwise returns false.
|
inline |
Returns the list widget containing this item.
|
virtual |
Returns true if this item's text is less then other item's text, otherwise returns false.
QListWidgetItem & QListWidgetItem::operator= | ( | const QListWidgetItem & | other | ) |
Copy assigns from other and returns a reference to this object. The value for type() and listWidget() are not copied.
|
virtual |
Reads the item from stream in.
|
inline |
Sets the background brush of the list item to the given brush.
|
inlinedeprecatedvirtual |
|
inline |
Sets the check state for this list item to state.
|
virtual |
Sets the data for a given role to the given value. Reimplement this method if you need extra roles or special behavior for certain roles.
void QListWidgetItem::setFlags | ( | Qt::ItemFlags | flags | ) |
Sets the item flags for the list item to flags.
|
inline |
Sets the font used when painting this item to the given font.
|
inline |
Sets the foreground brush of this list item to the given brush.
|
inline |
Hides this list item if hide is true, otherwise shows the item. You must add this list item to the QListWidget before calling this method.
|
inline |
Sets the icon for this list item to the given icon.
|
inline |
Sets the selected state of the item to select.
|
inline |
Sets the size hint for the list item to be size. If no size hint is set the item delegate will compute the size hint based on the item data.
|
inline |
Sets the status tip for the list item to the text specified by statusTip. QListWidget mouseTracking needs to be enabled for this feature to work.
|
inline |
Sets the text for the list widget item's to the given text.
|
inline |
Sets this list item text alignment to alignment.
|
inlinedeprecated |
|
inline |
Sets the tooltip for this list item to the text specified by toolTip.
|
inline |
Sets the "What's This?" help for this list item to the text specified by whatsThis.
|
inline |
Returns the size hint set for this list item.
|
inline |
Returns the status tip for this list item.
|
inline |
Returns the text for this list item.
|
inline |
Returns the text alignment for this list item.
|
inlinedeprecated |
Returns the color used to display the list item's text.
|
inline |
Returns the tooltip for this list item.
|
inline |
Returns the type passed to the QListWidgetItem constructor.
|
inline |
Returns the list item's "What's This?" help text.
|
virtual |
Writes the item to stream out.
|
related |
Writes item to the stream and returns a reference to the stream. This operator uses QListWidgetItem::write().
Refer to Serializing Data Types for additional information.
|
related |
Reads from the stream into item and returns a reference to the stream. This operator uses QListWidgetItem::read().
Refer to Serializing Data Types for additional information.