⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qlistviewitem.3qt

📁 Linux 下的图形编程环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
Note that the order is changed according to QListViewItem::key() unless the list view's sorting is disabled using QListView::setSorting( -1 )..PPSee also setText()..SH "QListViewItem::~QListViewItem () \fC[virtual]\fR"Destroys the item, deleting all its children, freeing up all allocated resources..SH "void QListViewItem::activate () \fC[virtual protected]\fR"This virtual function is called whenever the user clicks on this item or presses Space on it..PPSee also activatedPos()..PPReimplemented in QCheckListItem..SH "bool QListViewItem::activatedPos ( QPoint & pos ) \fC[protected]\fR"When called from a reimplementation of activate(), this function gives information on how the item was activated. Otherwise, the behaviour is undefined..PPIf activate() was caused by a mouse press, the function sets \fIpos\fR to where the user clicked and returns TRUE, otherwise it returns FALSE and does not change \fIpos.\fR.PPPos is relative to the top-left corner of this item..PPWe recommend not using this function; it will most likely be obsoleted at the first opportunity..PPSee also activate()..SH "int QListViewItem::childCount () const"Returns the current number of children of this item..SH "int QListViewItem::depth () const"Returns the depth of this item..SH "void QListViewItem::enforceSortOrder () const \fC[virtual protected]\fR"Makes sure that this object's children are sorted appropriately..PPThis only works if every item in the chain from the root item to this item is sorted appropriately..PPSee also sortChildItems()..SH "QListViewItem* QListViewItem::firstChild () const"Returns a pointer to the first (top) child of this item, or a null pointer if this item has no children..PPNote that the children are not guaranteed to be sorted properly. QListView and QListViewItem try to postpone or avoid sorting to the greatest degree possible, in order to keep the user interface snappy..PPSee also nextSibling()..SH "int QListViewItem::height () const"Returns the height of this item in pixels. This does not include the height of any children; totalHeight() returns that..SH "void QListViewItem::insertItem ( QListViewItem * newChild ) \fC[virtual]\fR"Inserts \fInewChild\fR into its list of children. You should not need to call this function; it is called automatically by the constructor of \fInewChild.\fR.PPThis function works even if this item is not contained in a list view..SH "void QListViewItem::invalidateHeight () \fC[virtual]\fR"Invalidates the cached total height of this item including all open children..PPThis function works even if this item is not contained in a list view..PPSee also setHeight(), height() and totalHeight()..SH "bool QListViewItem::isExpandable () const"Returns TRUE if this item is expandable even when it has no children..SH "bool QListViewItem::isOpen () const"Returns TRUE if this list view item has children \fIand\fR they are potentially visible, or FALSE if the item has no children or they are hidden..PPSee also setOpen()..SH "bool QListViewItem::isSelectable () const"Returns TRUE if the item is selectable (as it is by default) and FALSE if it isn't..PPSee also setSelectable()..SH "bool QListViewItem::isSelected () const"Returns TRUE if this item is selected, or FALSE if it is not..PPSee also setSelected(), QListView::setSelected() and QListView::selectionChanged()..SH "QListViewItem * QListViewItem::itemAbove ()"Returns a pointer to the item immediately above this item on the screen. This is usually the item's closest older sibling, but may also be its parent or its next older sibling's youngest child, or something else if anyoftheabove->height() returns 0. Returns a null pointer if there is no item immediately above this item..PPThis function assumes that all parents of this item are open (ie. that this item is visible, or can be made visible by scrolling)..PPSee also itemBelow() and QListView::itemRect()..SH "QListViewItem * QListViewItem::itemBelow ()"Returns a pointer to the item immediately below this item on the screen. This is usually the item's eldest child, but may also be its next younger sibling, its parent's next younger sibling, grandparent's etc., or something else if anyoftheabove->height() returns 0. Returns a null pointer if there is no item immediately above this item..PPThis function assumes that all parents of this item are open (ie. that this item is visible, or can be made visible by scrolling)..PPSee also itemAbove() and QListView::itemRect()..SH "int QListViewItem::itemPos () const"Returns the y coordinate of \fIitem\fR in the list view's coordinate system. This functions is normally much slower than QListView::itemAt(), but it works for all items, while QListView::itemAt() normally works only for items on the screen..PPSee also QListView::itemAt(), QListView::itemRect() and QListView::itemPos()..SH "QString QListViewItem::key ( int column, bool ascending ) const \fC[virtual]\fR"Returns a key that can be used for sorting by column \fIcolumn.\fR The default implementation returns text(). Derived classes may also incorporate the order indicated by \fIascending\fR into this key, although this is not recommended..PPYou can use this function to sort by non-alphabetic data. This code excerpt sort by file modification date, for example.PP.nf.br    if ( column == 3 ) {.br        QDateTime epoch( QDate( 1980, 1, 1 ) );.br        tmpString.sprintf( "%08d", epoch.secsTo( myFile.lastModified() ) );.br    } else {.br        // .....br    }.br    return tmpString;.fi.PPSee also sortChildItems()..SH "QListView * QListViewItem::listView () const"Returns a pointer to the listview containing this item..SH "void QListViewItem::moveItem ( QListViewItem * after )"Moves this item after the item \fIafter.\fR This means it will get the sibling exactly after the item \fIafter.\fR To move an item in the hierarchy, use takeItem() and insertItem()..SH "QListViewItem* QListViewItem::nextSibling () const"Returns a pointer to the sibling item below this item, or a null pointer if there is no sibling item after this item..PPNote that the siblings are not guaranteed to be sorted properly. QListView and QListViewItem try to postpone or avoid sorting to the greatest degree possible, in order to keep the user interface snappy..PPSee also firstChild()..SH "void QListViewItem::paintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h, GUIStyle s ) \fC[virtual]\fR"Paints a set of branches from this item to (some of) its children..PP\fIp\fR is set up with clipping and translation so that you can draw only in the rectangle you need to; \fIcg\fR is the color group to use; the update rectangle is at 0, 0 and has size \fIw, h.\fR The top of the rectangle you own is at \fIy\fR (which is never greater than 0 but can be outside the window system's allowed coordinate range)..PPThe update rectangle is in an undefined state when this function is called; this function must draw on \fIall\fR of the pixels..PPSee also paintCell() and QListView::drawContentsOffset()..PPReimplemented in QCheckListItem..SH "void QListViewItem::paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ) \fC[virtual]\fR"This virtual function paints the contents of one column of one item..PP\fIp\fR is a QPainter open on the relevant paint device. \fIp\fR is translated so 0, 0 is the top left pixel in the cell and \fIwidth-1,\fR height()-1 is the bottom right pixel \fIin\fR the cell. The other properties of \fIp\fR (pen, brush etc) are undefined. \fIcg\fR is the color group to use. \fIcolumn\fR is the logical column number within the item that is to be painted; 0 is the column which may contain a tree..PPThis function may use QListView::itemMargin() for readability spacing on the left and right sides of information such as text, and should honor isSelected() and QListView::allColumnsShowFocus()..PPIf you reimplement this function, you should also reimplement width()..PPThe rectangle to be painted is in an undefined state when this function is called, so you \fImust\fR draw on all the pixels. The painter \fIp\fR has the right font on entry..PPSee also paintBranches() and QListView::drawContentsOffset()..PPReimplemented in QCheckListItem..SH "void QListViewItem::paintFocus ( QPainter * p, const QColorGroup & cg, const QRect & r ) \fC[virtual]\fR"Paints a focus indication on the rectangle \fIr\fR using painter \fIp\fR and colors \fIcg.\fR.PP\fIp\fR is already clipped..PPSee also paintCell(), paintBranches() and QListView::setAllColumnsShowFocus()..SH "QListViewItem* QListViewItem::parent () const"Returns a pointer to the parent of this item, or a null pointer if this item has no parent..PPSee also firstChild() and nextSibling()..SH "const QPixmap * QListViewItem::pixmap ( int column ) const \fC[virtual]\fR"Returns a pointer to the pixmap for \fIcolumn,\fR or a null pointer if there is no pixmap for \fIcolumn.\fR.PPThis function works even if this item is not contained in a list view, but reimplementations of it are not required to work properly in that case..PPSee also setText() and setPixmap()..SH "void QListViewItem::removeItem ( QListViewItem * item ) \fC[virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPThis function has been renamed takeItem()..SH "void QListViewItem::repaint () const"Repaints this item on the screen, if it is currently visible..SH "void QListViewItem::setExpandable ( bool enable ) \fC[virtual]\fR"Sets this item to be expandable even if it has no children if \fIenable\fR is TRUE, and to be expandable only if it has children if \fIenable\fR is FALSE (the default)..PPThe dirview example uses this in the canonical fashion: It checks whether the directory is empty in setup() and calls setExpandable(TRUE) if not, and in setOpen() it reads the contents of the directory and inserts items accordingly. This strategy means that dirview can display the entire file system without reading very much at start-up..PPNote that root items are not expandable by the user unless QListView::setRootIsDecorated() is set to TRUE..PPSee also setSelectable()..SH "void QListViewItem::setHeight ( int height ) \fC[virtual protected]\fR"Sets this item's own height to \fIheight\fR pixels. This implicitly changes totalHeight() too..PPNote that e.g. a font change causes this height to be overwritten unless you reimplement setup()..PPFor best results in Windows style, we suggest using an even number of pixels..PPSee also height(), totalHeight() and isOpen();..SH "void QListViewItem::setOpen ( bool o ) \fC[virtual]\fR"Sets this item to be open (its children are visible) if \fIo\fR is TRUE, and to be closed (its children are not visible) if \fIo\fR is FALSE..PPAlso does some bookkeeping..PPSee also height() and totalHeight()..PPExamples:.(ldirview/main.cpp.)l.SH "void QListViewItem::setPixmap ( int column, const QPixmap & pm ) \fC[virtual]\fR"Sets the pixmap in column \fIcolumn\fR to \fIpm,\fR if \fIpm\fR is non-null and \fIcolumn\fR is non-negative..PPSee also pixmap() and setText()..SH "void QListViewItem::setSelectable ( bool enable ) \fC[virtual]\fR"Sets this items to be selectable if \fIenable\fR is TRUE (the default) or not to be selectable if \fIenable\fR is FALSE..PPThe user is not able to select a non-selectable item using either the keyboard or mouse. The application programmer still can, of course..PPSee also isSelectable()..SH "void QListViewItem::setSelected ( bool s ) \fC[virtual]\fR"Sets this item to be selected \fIs\fR is TRUE, and to not be selected if \fIo\fR is FALSE..PPThis function does not maintain any invariants or repaint anything - QListView::setSelected() does that..PPSee also height() and totalHeight()..SH "void QListViewItem::setText ( int column, const QString & text ) \fC[virtual]\fR"Sets the text in column \fIcolumn\fR to \fItext,\fR if \fIcolumn\fR is a valid column number and \fItext\fR is non-null..PPIf \fItext()\fR has been reimplemented, this function may be a no-op..PPSee also text(), key() and invalidate()..SH "void QListViewItem::setup () \fC[virtual]\fR"This virtual function is called before the first time QListView needs to know the height or any other graphical attribute of this object, and whenever the font, GUI style or colors of the list view change..PPThe default calls widthChanged() and sets the item's height to the height of a single line of text in the list view's font. (If you use icons, multi-line text etc. you will probably need to call setHeight() yourself or reimplement this.)..PPReimplemented in QCheckListItem..SH "void QListViewItem::sort ()"(Re)sorts all child items of this item using the last sorting configuration (sort column and direction)..PPSee also enforceSortOrder()..SH "void QListViewItem::sortChildItems ( int column, bool ascending ) \fC[virtual]\fR"Sorts the children of this item by the return values of key(\fIcolumn, ascending),\fR in ascending order if \fIascending\fR is TRUE and in descending order of \fIdescending\fR is FALSE..PPAsks some of the children to sort their children. (QListView and QListViewItem ensure that all on-screen objects are properly sorted, but may avoid or defer sorting other objects in order to be more responsive.).PPSee also key()..SH "void QListViewItem::takeItem ( QListViewItem * item ) \fC[virtual]\fR"Removes \fIitem\fR from this object's list of children and causes an update of the screen display. The item is not deleted. You should normally not need to call this function, as QListViewItem::~QListViewItem() calls it. The normal way to delete an item is \fCdelete..PP\fBWarning:\fR\fR This function leaves \fIitem\fR and its children in a state where most member functions are unsafe. Only the few functions that are explicitly documented to work in this state may be used then..PPSee also QListViewItem::insertItem()..SH "QString QListViewItem::text ( int column ) const \fC[virtual]\fR"Returns the text in column \fIcolumn,\fR or a null string if there is no text in that column..PPThis function works even if this item is not contained in a list view, but reimplementations of it are not required to work properly in that case..PPSee also key() and paintCell()..PPReimplemented in QCheckListItem..SH "int QListViewItem::totalHeight () const"Returns the total height of this object, including any visible children. This height is recomputed lazily and cached for as long as possible..PPsetHeight() can be used to set the item's own height, setOpen() to show or hide its children, and invalidateHeight() to invalidate the cached height..PPSee also height()..SH "int QListViewItem::width ( const QFontMetrics & fm, const QListView * lv, int c ) const \fC[virtual]\fR"Returns the number of pixels of width required to draw column \fIc\fR of listview \fIlv,\fR using the metrics \fIfm\fR without cropping. The list view containing this item may use this information, depending on the QListView::WidthMode settings for the column..PPThe default implementation returns the width of the bounding rectangle of the text of column \fIc.\fR.PPSee also listView(), widthChanged(), QListView::setColumnWidthMode() and QListView::itemMargin()..PPReimplemented in QCheckListItem..SH "void QListViewItem::widthChanged ( int c=-1 ) const"Call this function when the value of width() may have changed for column \fIc.\fR Normally, you should call this if text(c) changes. Passing -1 for \fIc\fR indicates all columns may have changed. For efficiency, you should do this if more than one call to widthChanged() is required..PPSee also  width()..SH "SEE ALSO".BR http://doc.trolltech.com/qlistviewitem.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qlistviewitem.3qt) and the Qtversion (2.3.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -