📄 qlistview.3qt
字号:
.)l addressbook/centralwidget.cpp, checklists/checklists.cpp, listviews/listviews.cpp, and qutlook/centralwidget.cpp..SH "void QListView::clearSelection ()\fC [virtual]\fR"Sets all the items to be not selected, updates the list view as necessary, and emits the selectionChanged() signals. Note that for Multi selection list views this function needs to iterate over \fIall\fR items..PPSee also setSelected() and multiSelection..PPExample: addressbook/centralwidget.cpp..SH "void QListView::clicked ( QListViewItem * item )\fC [signal]\fR"This signal is emitted whenever the user clicks (mouse pressed \fIand\fR mouse released) in the list view. \fIitem\fR is the clicked list view item, or 0 if the user didn't click on an item..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..PPExample: addressbook/centralwidget.cpp..SH "void QListView::clicked ( QListViewItem * item, const QPoint & pnt, int c )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted whenever the user clicks (mouse pressed \fIand\fR mouse released) in the list view. \fIitem\fR is the clicked list view item, or 0 if the user didn't click on an item. \fIpnt\fR is the position where the user has clicked in global coordinates. If \fIitem\fR is not 0, \fIc\fR is the list view column into which the user pressed; if \fIitem\fR is 0 \fIc\fR's value is undefined..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::collapsed ( QListViewItem * item )\fC [signal]\fR"This signal is emitted when the \fIitem\fR has been collapsed, i.e. when the children of \fIitem\fR are hidden..PPSee also setOpen() and expanded()..SH "int QListView::columnAlignment ( int column ) const"Returns the alignment of column \fIcolumn\fR. The default is AlignAuto..PPSee also Qt::AlignmentFlags..SH "QString QListView::columnText ( int c ) const"Returns the text of column \fIc\fR..PPSee also setColumnText()..SH "int QListView::columnWidth ( int c ) const"Returns the width of column \fIc\fR..PPSee also setColumnWidth()..SH "WidthMode QListView::columnWidthMode ( int c ) const"Returns the WidthMode for column \fIc\fR..PPSee also setColumnWidthMode()..SH "int QListView::columns () const"Returns the number of columns in this list view. See the "columns" property for details..SH "void QListView::contentsMouseDoubleClickEvent ( QMouseEvent * e )\fC [virtual protected]\fR"Processes the mouse double-click event \fIe\fR on behalf of the viewed widget..PPReimplemented from QScrollView..SH "void QListView::contentsMouseMoveEvent ( QMouseEvent * e )\fC [virtual protected]\fR"Processes the mouse move event \fIe\fR on behalf of the viewed widget..PPExample: dirview/dirview.cpp..PPReimplemented from QScrollView..SH "void QListView::contentsMousePressEvent ( QMouseEvent * e )\fC [virtual protected]\fR"Processes the mouse press event \fIe\fR on behalf of the viewed widget..PPExample: dirview/dirview.cpp..PPReimplemented from QScrollView..SH "void QListView::contentsMouseReleaseEvent ( QMouseEvent * e )\fC [virtual protected]\fR"Processes the mouse release event \fIe\fR on behalf of the viewed widget..PPExample: dirview/dirview.cpp..PPReimplemented from QScrollView..SH "void QListView::contextMenuRequested ( QListViewItem * item, const QPoint & pos, int col )\fC [signal]\fR"This signal is emitted when the user invokes a context menu with the right mouse button or with special system keys. If the keyboard was used \fIitem\fR is the current item; if the mouse was used, \fIitem\fR is the item under the mouse pointer or 0 if there is no item under the mouse pointer. If no item is clicked, the column index emitted is -1..PP\fIpos\fR is the position for the context menu in the global coordinate system..PP\fIcol\fR is the column on which the user pressed, or -1 if the signal was triggered by a key event..PPExample: listviews/listviews.cpp..SH "void QListView::currentChanged ( QListViewItem * )\fC [signal]\fR"This signal is emitted whenever the current item has changed (normally after the screen update). The current item is the item responsible for indicating keyboard focus..PPThe argument is the newly current item, or 0 if the change made no item current. This can happen, for example, if all items in the list view are deleted..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..PPSee also setCurrentItem() and currentItem()..PPExample: listviews/listviews.cpp..SH "QListViewItem * QListView::currentItem () const"Returns the current item, or 0 if there isn't one..PPSee also setCurrentItem()..PPExamples:.)l addressbook/centralwidget.cpp, listviews/listviews.cpp, and qutlook/centralwidget.cpp..SH "RenameAction QListView::defaultRenameAction () const"Returns what action to perform when the editor loses focus during renaming. See the "defaultRenameAction" property for details..SH "void QListView::doAutoScroll ()\fC [protected slot]\fR"This slot handles auto-scrolling when the mouse button is pressed and the mouse is outside the widget..SH "void QListView::doubleClicked ( QListViewItem *, const QPoint &, int )\fC [signal]\fR"This signal is emitted whenever an item is double-clicked. It's emitted on the second button press, not the second button release. The arguments are the relevant QListViewItem (may be 0), the point in global coordinates and the relevant column (or -1 if the click was outside the list)..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::doubleClicked ( QListViewItem * item )\fC [signal]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code. (use doubleClicked( QListViewItem *, const QPoint&, int )).PPThis signal is emitted whenever an item is double-clicked. It's emitted on the second button press, not the second button release. \fIitem\fR is the list view item on which the user did the double-click..SH "QDragObject * QListView::dragObject ()\fC [virtual protected]\fR"If the user presses the mouse on an item and starts moving the mouse, and the item allow dragging (see QListViewItem::setDragEnabled()), this function is called to get a drag object and a drag is started unless dragObject() returns 0..PPBy default this function returns 0. You should reimplement it and create a QDragObject depending on the selected items..SH "void QListView::drawContentsOffset ( QPainter * p, int ox, int oy, int cx, int cy, int cw, int ch )\fC [virtual protected]\fR"Calls QListViewItem::paintCell() and QListViewItem::paintBranches() as necessary for all list view items that require repainting in the \fIcw\fR pixels wide and \fIch\fR pixels high bounding rectangle starting at position \fIcx\fR, \fIcy\fR with offset \fIox\fR, \fIoy\fR. Uses the painter \fIp\fR..PPReimplemented from QScrollView..SH "void QListView::dropped ( QDropEvent * e )\fC [signal]\fR"This signal is emitted, when a drop event occurred on the viewport (not onto an item)..PP\fIe\fR provides all the information about the drop..SH "void QListView::ensureItemVisible ( const QListViewItem * i )"Ensures that item \fIi\fR is visible, scrolling the list view vertically if necessary and opening (expanding) any parent items if this is required to show the item..PPSee also itemRect() and QScrollView::ensureVisible()..SH "bool QListView::eventFilter ( QObject * o, QEvent * e )\fC [virtual]\fR"Redirects the event \fIe\fR relating to object \fIo\fR, for the viewport to mousePressEvent(), keyPressEvent() and friends..PPReimplemented from QScrollView..SH "void QListView::expanded ( QListViewItem * item )\fC [signal]\fR"This signal is emitted when \fIitem\fR has been expanded, i.e. when the children of \fIitem\fR are shown..PPSee also setOpen() and collapsed()..SH "QListViewItem * QListView::findItem ( const QString & text, int column, ComparisonFlags compare = ExactMatch | CaseSensitive ) const"Finds the first list view item in column \fIcolumn\fR, that matches \fItext\fR and returns the item, or returns 0 of no such item could be found. Pass OR-ed together Qt::StringComparisonMode values in the \fIcompare\fR flag, to control how the matching is performed. The default comparison mode is case-sensitive, exact match..SH "QListViewItem * QListView::firstChild () const"Returns the first item in this QListView. Returns 0 if there is no first item..PPA list view's items can be traversed using firstChild() and nextSibling() or using a QListViewItemIterator..PPSee also itemAt(), QListViewItem::itemBelow(), and QListViewItem::itemAbove()..PPExamples:.)l addressbook/centralwidget.cpp and listviews/listviews.cpp..SH "QHeader * QListView::header () const"Returns the QHeader object that manages this list view's columns. Please don't modify the header behind the list view's back..PPYou may safely call QHeader::setClickEnabled(), QHeader::setResizeEnabled(), QHeader::setMovingEnabled(), QHeader::hide() and all the const QHeader functions..PPExamples:.)l listviews/listviews.cpp and qdir/qdir.cpp..SH "void QListView::hideColumn ( int column )"Hides the column specified at \fIcolumn\fR. This is a convenience function that calls setColumnWidth( \fIcolumn\fR, 0 )..PPNote: The user may still be able to resize the hidden column using the header handles. To prevent this, call setResizeEnabled(FALSE, \fIcolumn\fR) on the list views header..PPSee also setColumnWidth()..SH "void QListView::insertItem ( QListViewItem * i )\fC [virtual]\fR"Inserts item \fIi\fR into the list view as a top-level item. You do not need to call this unless you've called takeItem(\fIi\fR) or QListViewItem::takeItem(\fIi\fR) and need to reinsert \fIi\fR elsewhere..PPSee also QListViewItem::takeItem() and takeItem()..SH "void QListView::invertSelection ()\fC [virtual slot]\fR"Inverts the selection. Only works in Multi and Extended selection modes..SH "bool QListView::isMultiSelection () const"Returns TRUE if the list view is in multi-selection or extended-selection mode; otherwise returns FALSE. See the "multiSelection" property for details..SH "bool QListView::isOpen ( const QListViewItem * item ) const"Identical to \fIitem\fR->isOpen(). Provided for completeness..PPSee also setOpen()..SH "bool QListView::isRenaming () const"Returns TRUE if an item is being renamed; otherwise returns FALSE..SH "bool QListView::isSelected ( const QListViewItem * i ) const"Returns TRUE if the list view item \fIi\fR is selected; otherwise returns FALSE..PPSee also QListViewItem::isSelected()..SH "QListViewItem * QListView::itemAt ( const QPoint & viewPos ) const"Returns the list view item at \fIviewPos\fR. Note that \fIviewPos\fR is in the viewport()'s coordinate system, not in the list view's own, much larger, coordinate system..PPitemAt() returns 0 if there is no such item..PPNote that you also get the pointer to the item if \fIviewPos\fR points to the root decoration (see setRootIsDecorated()) of the item. To check whether or not \fIviewPos\fR is on the root decoration of the item, you can do something like this:.PP.nf.br QListViewItem *i = itemAt( p );.br if ( i ) {.br if ( p.x() > header()->sectionPos( header()->mapToIndex( 0 ) ) +.br treeStepSize() * ( i->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ||.br p.x() < header()->sectionPos( header()->mapToIndex( 0 ) ) ) {.br ; // p is not on root decoration.br else.br ; // p is on the root decoration.br }.br.fi.PPThis might be interesting if you use this function to find out where the user clicked and if you want to start a drag (which you do not want to do if the user clicked onto the root decoration of an item)..PPSee also itemPos(), itemRect(), and viewportToContents()..SH "int QListView::itemMargin () const"Returns the advisory item margin that list items may use. See the "itemMargin" property for details..SH "int QListView::itemPos ( const QListViewItem * item )"Returns the y-coordinate of \fIitem\fR in the list view's coordinate system. This function is normally much slower than itemAt() but it works for all items, whereas itemAt() normally works only for items on the screen..PPThis is a thin wrapper around QListViewItem::itemPos()..PPSee also itemAt() and itemRect()..SH "QRect QListView::itemRect ( const QListViewItem * i ) const"Returns the rectangle on the screen that item \fIi\fR occupies in viewport()'s coordinates, or an invalid rectangle if \fIi\fR is 0 or is not currently visible..PPThe rectangle returned does not include any children of the rectangle (i.e. it uses QListViewItem::height(), rather than QListViewItem::totalHeight()). If you want the rectangle to include children you can use something like this:.PP.nf.br QRect r( listView->itemRect( item ) );.br r.setHeight( (QCOORD)(QMIN( item->totalHeight(),.br listView->viewport->height() - r.y() ) ) ).br.fi.PPNote the way it avoids too-high rectangles. totalHeight() can be much larger than the window system's coordinate system allows..PPitemRect() is comparatively slow. It's best to call it only for items that are probably on-screen..SH "void QListView::itemRenamed ( QListViewItem * item, int col, const QString & text )\fC [signal]\fR"This signal is emitted when \fIitem\fR has been renamed to \fItext\fR, e.g. by in in-place renaming, in column \fIcol\fR..PPSee also QListViewItem::setRenameEnabled()..SH "void QListView::itemRenamed ( QListViewItem * item, int col )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted when \fIitem\fR has been renamed, e.g. by in-place renaming, in column \fIcol\fR..PPSee also QListViewItem::setRenameEnabled()..SH "QListViewItem * QListView::lastItem () const"Returns the last item in the list view tree. Returns 0 if there are no items in the QListView..PPThis function is slow because it traverses the entire tree to find the last item..SH "void QListView::mouseButtonClicked ( int button, QListViewItem * item, const QPoint & pos, int c )\fC [signal]\fR"This signal is emitted whenever the user clicks (mouse pressed \fIand\fR mouse released) in the list view at position \fIpos\fR. \fIbutton\fR is the mouse button that the user pressed, \fIitem\fR is the clicked list view item or 0 if the user didn't click on an item. If \fIitem\fR is not 0, \fIc\fR is the list view column into which the user pressed; if \fIitem\fR is 0 \fIc\fR's value is undefined..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::mouseButtonPressed ( int button, QListViewItem * item, const QPoint & pos, int c )\fC [signal]\fR"This signal is emitted whenever the user pressed the mouse button in the list view at position \fIpos\fR. \fIbutton\fR is the mouse button which the user pressed, \fIitem\fR is the pressed list view item or 0 if the user didn't press on an item. If \fIitem\fR is not 0, \fIc\fR is the list view column into which the user pressed; if \fIitem\fR is 0 \fIc\fR's value is undefined..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::onItem ( QListViewItem * i )\fC [signal]\fR"This signal is emitted when the user moves the mouse cursor onto item \fIi\fR, similar to the QWidget::enterEvent() function..SH "void QListView::onViewport ()\fC [signal]\fR"This signal is emitted when the user moves the mouse cursor from an item to an empty part of the list view..SH "void QListView::paintEmptyArea ( QPainter * p, const QRect & rect )\fC [virtual protected]\fR"Paints \fIrect\fR so that it looks like empty background using painter \fIp\fR. \fIrect\fR is in widget coordinates, ready to be fed to \fIp\fR..PPThe default function fills \fIrect\fR with the viewport()->backgroundBrush()..SH "void QListView::pressed ( QListViewItem * item )\fC [signal]\fR"This signal is emitted whenever the user presses the mouse button in a list view. \fIitem\fR is the list view item on which the user pressed the mouse button, or 0 if the user didn't press the mouse on an item..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::pressed ( QListViewItem * item, const QPoint & pnt, int c )\fC [signal]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis signal is emitted whenever the user presses the mouse button in a list view. \fIitem\fR is the list view item on which the user pressed the mouse button, or 0 if the user didn't press the mouse on an item. \fIpnt\fR is the position of the mouse cursor in global coordinates, and \fIc\fR is the column where the mouse cursor was when the user pressed the mouse button..PP\fBWarning:\fR Do not delete any QListViewItem objects in slots connected to this signal..SH "void QListView::removeColumn ( int index )\fC [virtual]\fR"Removes the column at position \fIindex\fR..PPIf no columns remain after the column is removed, the list view will be cleared..PPSee also clear()..SH "void QListView::removeItem ( QListViewItem * item )\fC [virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis function has been renamed takeItem()..SH "void QListView::repaintItem ( const QListViewItem * item ) const"Repaints \fIitem\fR on the screen if \fIitem\fR is currently visible. Takes care to avoid multiple repaints..SH "void QListView::resizeEvent ( QResizeEvent * e )\fC [virtual protected]\fR"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -