Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QListWidgetItem Class Reference
[QtGui module]

The QListWidgetItem class provides an item for use with the QListWidget item view class. More...

#include <QListWidgetItem>

Public Functions

Static Public Members

Related Non-Members

  • QDataStream & operator<< ( QDataStream & out, const QListWidgetItem & item )
  • QDataStream & operator>> ( QDataStream & in, QListWidgetItem & item )

Detailed Description

The QListWidgetItem class provides an item for use with the QListWidget item view class.

The QListWidgetItem class provides a list item for use with the QListWidget class. List items provide label information that is displayed in list widgets.

The item view convenience 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 automatically inserted into a list when they are constructed by specifying the list widget:

        new QListWidgetItem(tr("Hazel"), listWidget);

They can also be created without a parent widget, and later inserted into a list (see QListWidget::insertItem()).

List items are typically used to display text() and an icon(). These are set with the setText() and setIcon() functions. The appearance of the text can be customized with setFont(), setTextColor(), and setBackgroundColor(). List items can be aligned using the setAlignment() function. Tooltips, status tips and "What's This?" help can be added to list items with setToolTip(), setStatusTip(), and setWhatsThis().

Items can be made checkable by calling setFlags() with the appropriate value (see Qt::ItemFlags). Checkable items can be checked and unchecked with the setChecked() function. The corresponding checked() function indicates whether the item is currently checked.

The isItemHidden() function can be used to determine whether the item is hidden. Items can be hidden with setItemHidden().

See also QListWidget and Model/View Programming.


Member Function Documentation

QListWidgetItem::QListWidgetItem ( QListWidget * parent = 0, int type = Type )

Constructs an empty list widget item of the specified type with the given parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().

See also type().

QListWidgetItem::QListWidgetItem ( const QString & text, QListWidget * parent = 0, int type = Type )

Constructs an empty list widget item of the specified type with the given text and parent. If the parent is not specified, the item will need to be inserted into a list widget with QListWidget::insertItem().

See also type().

QListWidgetItem::~QListWidgetItem ()   [virtual]

Destroys the list item.

QColor QListWidgetItem::backgroundColor () const

Returns the color used to display the list item's background.

See also setBackgroundColor() and textColor().

Qt::CheckState QListWidgetItem::checkState () const

Returns the checked state of the list item (see Qt::CheckState.

See also setCheckState() and flags().

QListWidgetItem * QListWidgetItem::clone () const   [virtual]

Creates an exact copy of the item.

QVariant QListWidgetItem::data ( int role ) const   [virtual]

This function returns the item's data for a given role (see {Qt::ItemDataRole}). Reimplement this function if you need extra roles or special behavior for certain roles.

See also setData().

Qt::ItemFlags QListWidgetItem::flags () const

Returns the item flags for this item (see {Qt::ItemFlags}).

See also setFlags().

QFont QListWidgetItem::font () const

Returns the font used to display this list item's text.

See also setFont().

QIcon QListWidgetItem::icon () const

Returns the list item's icon.

See also setIcon().

QListWidget * QListWidgetItem::listWidget () const

Returns the list widget that contains the item.

void QListWidgetItem::read ( QDataStream & in )   [virtual]

Reads the item from stream in.

See also write().

void QListWidgetItem::setBackgroundColor ( const QColor & color )   [virtual]

Sets the background color of the list item to the given color.

See also backgroundColor() and setTextColor().

void QListWidgetItem::setCheckState ( Qt::CheckState state )

Sets the check state of the list item to state.

See also checkState().

void QListWidgetItem::setData ( int role, const QVariant & value )   [virtual]

This function sets the data for a given role to the given value (see Qt::ItemDataRole). Reimplement this function if you need extra roles or special behavior for certain roles.

See also data().

void QListWidgetItem::setFlags ( Qt::ItemFlags flags )

Sets the item flags for the list item to flags (see Qt::ItemFlags).

See also flags().

void QListWidgetItem::setFont ( const QFont & font )

Sets the font used when painting the item to the given font.

See also font().

void QListWidgetItem::setIcon ( const QIcon & icon )

Sets the icon for the list item to the given icon.

See also icon().

void QListWidgetItem::setStatusTip ( const QString & statusTip )

Sets the status tip for the list item to the text specified by statusTip.

See also statusTip(), setToolTip(), and setWhatsThis().

void QListWidgetItem::setText ( const QString & text )

Sets the text for the list widget item's to the given text.

See also text().

void QListWidgetItem::setTextAlignment ( int alignment )

Sets the list item's text alignment to alignment (see Qt::AlignmentFlag).

See also textAlignment().

void QListWidgetItem::setTextColor ( const QColor & color )

Sets the text color for the list item to the given color.

See also textColor() and setBackgroundColor().

void QListWidgetItem::setToolTip ( const QString & toolTip )

Sets the tooltip for the list item to the text specified by toolTip.

See also toolTip(), setStatusTip(), and setWhatsThis().

void QListWidgetItem::setWhatsThis ( const QString & whatsThis )

Sets the "What's This?" help for the list item to the text specified by whatsThis.

See also whatsThis(), setStatusTip(), and setToolTip().

QString QListWidgetItem::statusTip () const

Returns the list item's status tip.

See also setStatusTip().

QString QListWidgetItem::text () const

Returns the list item's text.

See also setText().

int QListWidgetItem::textAlignment () const

Returns the text alignment for the list item (see Qt::AlignmentFlag).

See also setTextAlignment().

QColor QListWidgetItem::textColor () const

Returns the used to display the list item's text.

See also setTextColor() and backgroundColor().

QString QListWidgetItem::toolTip () const

Returns the list item's tooltip.

See also setToolTip(), statusTip(), and whatsThis().

int QListWidgetItem::type () const

Returns the type passed to the QListWidgetItem constructor.

QString QListWidgetItem::whatsThis () const

Returns the list item's "What's This?" help text.

See also setWhatsThis(), statusTip(), and toolTip().

void QListWidgetItem::write ( QDataStream & out ) const   [virtual]

Writes the item to stream out.

See also read().

bool QListWidgetItem::operator< ( const QListWidgetItem & other ) const   [virtual]

Returns true if this item's text is less then other item's text; otherwise returns false.

QListWidgetItem & QListWidgetItem::operator= ( const QListWidgetItem & other )

Assigns other's data and flags to this item. Note that type() and listWidget() are not copied.

This function is useful when reimplementing clone().

See also data() and flags().


Member Variable Documentation

const int QListWidgetItem::Type

The default type for list widget items.

See also UserType and type().

const int QListWidgetItem::UserType

The minimum value for custom types. Values below UserType are reserved by Qt.

See also Type and type().


Related Non-Members

QDataStream & operator<< ( QDataStream & out, const QListWidgetItem & item )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Writes the list widget item item to stream out.

This operator uses QListWidgetItem::write().

See also Format of the QDataStream Operators.

QDataStream & operator>> ( QDataStream & in, QListWidgetItem & item )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reads a list widget item from stream in into item.

This operator uses QListWidgetItem::read().

See also Format of the QDataStream Operators.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Introduction

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web