QListViewItem

Section: Misc. Reference Manual Pages (3qt)
Updated: 2 February 2007
Index Return to Main Contents
 

NAME

QListViewItem - Implements a list view item  

SYNOPSIS

#include <qlistview.h>

Inherits Qt.

Inherited by QCheckListItem.

 

Public Members


QListViewItem ( QListView * parent )

QListViewItem ( QListViewItem * parent )

QListViewItem ( QListView * parent, QListViewItem * after )

QListViewItem ( QListViewItem * parent, QListViewItem * after )

QListViewItem ( QListView * parent, QString label1, QString label2 = QString::null, QString label3 = QString::null, QString label4 = QString::null, QString label5 = QString::null, QString label6 = QString::null, QString label7 = QString::null, QString label8 = QString::null )

QListViewItem ( QListViewItem * parent, QString label1, QString label2 = QString::null, QString label3 = QString::null, QString label4 = QString::null, QString label5 = QString::null, QString label6 = QString::null, QString label7 = QString::null, QString label8 = QString::null )

QListViewItem ( QListView * parent, QListViewItem * after, QString label1, QString label2 = QString::null, QString label3 = QString::null, QString label4 = QString::null, QString label5 = QString::null, QString label6 = QString::null, QString label7 = QString::null, QString label8 = QString::null )

QListViewItem ( QListViewItem * parent, QListViewItem * after, QString label1, QString label2 = QString::null, QString label3 = QString::null, QString label4 = QString::null, QString label5 = QString::null, QString label6 = QString::null, QString label7 = QString::null, QString label8 = QString::null )

virtual ~QListViewItem ()

virtual void insertItem ( QListViewItem * newChild )

virtual void takeItem ( QListViewItem * item )

virtual void removeItem ( QListViewItem * item ) (obsolete)

int height () const

virtual void invalidateHeight ()

int totalHeight () const

virtual int width ( const QFontMetrics & fm, const QListView * lv, int c ) const

void widthChanged ( int c = -1 ) const

int depth () const

virtual void setText ( int column, const QString & text )

virtual QString text ( int column ) const

virtual void setPixmap ( int column, const QPixmap & pm )

virtual const QPixmap * pixmap ( int column ) const

virtual QString key ( int column, bool ascending ) const

virtual int compare ( QListViewItem * i, int col, bool ascending ) const

virtual void sortChildItems ( int column, bool ascending )

int childCount () const

bool isOpen () const

virtual void setOpen ( bool o )

virtual void setup ()

virtual void setSelected ( bool s )

bool isSelected () const

virtual void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )

virtual void paintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h )

virtual void paintFocus ( QPainter * p, const QColorGroup & cg, const QRect & r )

QListViewItem * firstChild () const

QListViewItem * nextSibling () const

QListViewItem * parent () const

QListViewItem * itemAbove ()

QListViewItem * itemBelow ()

int itemPos () const

QListView * listView () const

virtual void setSelectable ( bool enable )

bool isSelectable () const

virtual void setExpandable ( bool enable )

bool isExpandable () const

void repaint () const

virtual void sort ()

void moveItem ( QListViewItem * after )

virtual void setDragEnabled ( bool allow )

virtual void setDropEnabled ( bool allow )

bool dragEnabled () const

bool dropEnabled () const

virtual bool acceptDrop ( const QMimeSource * mime ) const

void setVisible ( bool b )

bool isVisible () const

virtual void setRenameEnabled ( int col, bool b )

bool renameEnabled ( int col ) const

virtual void startRename ( int col )

virtual void setEnabled ( bool b )

bool isEnabled () const

virtual int rtti () const

virtual void setMultiLinesEnabled ( bool b )

bool multiLinesEnabled () const
 

Protected Members


virtual void enforceSortOrder () const

virtual void setHeight ( int height )

virtual void activate ()

bool activatedPos ( QPoint & pos )

virtual void dropped ( QDropEvent * e )

virtual void dragEntered ()

virtual void dragLeft ()

virtual void okRename ( int col )

virtual void cancelRename ( int col )
 

DESCRIPTION

The QListViewItem class implements a list view item.

A list view item is a multi-column object capable of displaying itself in a QListView.

The easiest way to use QListViewItem is to construct one with a few constant strings, and either a QListView or another QListViewItem as parent.


(void) new QListViewItem( listView, "Column 1", "Column 2" );
(void) new QListViewItem( listView->firstChild(), "A", "B", "C" );
We've discarded the pointers to the items since we can still access them via their parent listView. By default, QListView sorts its items; this can be switched off with QListView::setSorting(-1).

The parent must be another QListViewItem or a QListView. If the parent is a QListView, the item becomes a top-level item within that QListView. If the parent is another QListViewItem, the item becomes a child of that list view item.

If you keep the pointer, you can set or change the texts using setText(), add pixmaps using setPixmap(), change its mode using setSelectable(), setSelected(), setOpen() and setExpandable(). You'll also be able to change its height using setHeight(), and traverse its sub-items. You don't have to keep the pointer since you can get a pointer to any QListViewItem in a QListView using QListView::selectedItem(), QListView::currentItem(), QListView::firstChild(), QListView::lastItem() and QListView::findItem().

If you call delete on a list view item, it will be deleted as expected, and as usual for QObjects, if it has any child items (to any depth), all these will be deleted too.

QCheckListItems are list view items that have a checkbox or radio button and can be used in place of plain QListViewItems.

You can traverse the tree as if it were a doubly-linked list using itemAbove() and itemBelow(); they return pointers to the items directly above and below this item on the screen (even if none of them are actually visible at the moment).

Here's how to traverse all of an item's children (but not its children's children, etc.): Example:


QListViewItem * m