📄 qlistview.3qt
字号:
.br.ti -1c.BI "void \fBrightButtonClicked\fR ( QListViewItem *, const QPoint &, int )".br.ti -1c.BI "void \fBrightButtonPressed\fR ( QListViewItem *, const QPoint &, int )".br.ti -1c.BI "void \fBmouseButtonPressed\fR ( int button, QListViewItem * item, const QPoint & pos, int c )".br.ti -1c.BI "void \fBmouseButtonClicked\fR ( int button, QListViewItem * item, const QPoint & pos, int c )".br.ti -1c.BI "void \fBcontextMenuRequested\fR ( QListViewItem * item, const QPoint & pos, int col )".br.ti -1c.BI "void \fBonItem\fR ( QListViewItem * i )".br.ti -1c.BI "void \fBonViewport\fR ()".br.ti -1c.BI "void \fBexpanded\fR ( QListViewItem * item )".br.ti -1c.BI "void \fBcollapsed\fR ( QListViewItem * item )".br.ti -1c.BI "void \fBdropped\fR ( QDropEvent * e )".br.ti -1c.BI "void \fBitemRenamed\fR ( QListViewItem * item, int col, const QString & text )".br.ti -1c.BI "void \fBitemRenamed\fR ( QListViewItem * item, int col )".br.in -1c.SS "Properties".in +1c.ti -1c.BI "bool \fBallColumnsShowFocus\fR - whether items should show keyboard focus using all columns".br.ti -1c.BI "int \fBchildCount\fR - the number of parentless (top " "level" ") QListViewItem objects in this QListView \fI(read " "only" ")\fR".br.ti -1c.BI "int \fBcolumns\fR - the number of columns in this list view \fI(read " "only" ")\fR".br.ti -1c.BI "RenameAction \fBdefaultRenameAction\fR - whether the list view accepts the rename operation by default".br.ti -1c.BI "int \fBitemMargin\fR - the advisory item margin that list items may use".br.ti -1c.BI "bool \fBmultiSelection\fR - whether the list view is in multi-selection or extended-selection mode".br.ti -1c.BI "ResizeMode \fBresizeMode\fR - whether " "all" ", none or the only the last column should be resized".br.ti -1c.BI "bool \fBrootIsDecorated\fR - whether the list view shows open/close signs on root items".br.ti -1c.BI "SelectionMode \fBselectionMode\fR - the list view's selection mode".br.ti -1c.BI "bool \fBshowSortIndicator\fR - whether the list view header should display a sort indicator".br.ti -1c.BI "bool \fBshowToolTips\fR - whether this list view should show tooltips for truncated column texts".br.ti -1c.BI "int \fBtreeStepSize\fR - the number of pixels a child is offset from its parent".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBcontentsMousePressEvent\fR ( QMouseEvent * e )".br.ti -1c.BI "virtual void \fBcontentsMouseReleaseEvent\fR ( QMouseEvent * e )".br.ti -1c.BI "virtual void \fBcontentsMouseMoveEvent\fR ( QMouseEvent * e )".br.ti -1c.BI "virtual void \fBcontentsMouseDoubleClickEvent\fR ( QMouseEvent * e )".br.ti -1c.BI "virtual QDragObject * \fBdragObject\fR ()".br.ti -1c.BI "virtual void \fBstartDrag\fR ()".br.ti -1c.BI "virtual void \fBresizeEvent\fR ( QResizeEvent * e )".br.ti -1c.BI "virtual void \fBdrawContentsOffset\fR ( QPainter * p, int ox, int oy, int cx, int cy, int cw, int ch )".br.ti -1c.BI "virtual void \fBpaintEmptyArea\fR ( QPainter * p, const QRect & rect )".br.in -1c.SS "Protected Slots".in +1c.ti -1c.BI "void \fBupdateContents\fR ()".br.ti -1c.BI "void \fBdoAutoScroll\fR ()".br.in -1c.SH DESCRIPTIONThe QListView class implements a list/tree view..PPIt can display and control a hierarchy of multi-column items, and provides the ability to add new items at any time. Among others the user may select one or many items and sort the list in increasing or decreasing order by any column..PPThe simplest mode of use is to create a QListView, add some column headers using addColumn() and create one or more QListViewItem or QCheckListItem objects with the QListView as parent:.PP.nf.br QListView * table;.fi.PP.nf.br table->addColumn( "Qualified name" );.br table->addColumn( "Namespace" );.fi.PP.nf.br element = new QListViewItem( table, qName, namespaceURI );.fi.PPFurther nodes can be added to the listview object (the root of the tree) or as child nodes to QListViewItems:.PP.nf.br for ( int i = 0 ; i < attributes.length(); i++ ) {.br new QListViewItem( element, attributes.qName(i), attributes.uri(i) );.br }.fi.PP(From xml/tagreader-with-features/structureparser.cpp).PPThe main setup functions are: <center>.nf.TSl - l. Function Action addColumn() Adds a column with text and perhaps width. Columns are counted from the left starting with column 0. setColumnWidthMode() Sets the column to be resized automatically or not. setAllColumnsShowFocus() Sets whether items should show keyboard focus using all columns or just column 0. The default is to show focus just using column 0. setRootIsDecorated() Sets whether root items can be opened and closed by the user and have open/close decoration to their left. The default is FALSE. setTreeStepSize() Sets how many pixels an item's children are indented relative to their parent. The default is 20. This is mostly a matter of taste. setSorting().TE.fi</center>.PPTo handle events such as mouse presses on the list view, derived classes can reimplement the QScrollView functions: contentsMousePressEvent, contentsMouseReleaseEvent, contentsMouseDoubleClickEvent, contentsMouseMoveEvent, contentsDragEnterEvent, contentsDragMoveEvent, contentsDragLeaveEvent, contentsDropEvent, and contentsWheelEvent..PPThere are also several functions for mapping between items and coordinates. itemAt() returns the item at a position on-screen, itemRect() returns the rectangle an item occupies on the screen, and itemPos() returns the position of any item (whether it is on-screen or not). firstChild() returns the item at the top of the view (not necessarily on-screen) so you can iterate over the items using either QListViewItem::itemBelow() or a combination of QListViewItem::firstChild() and QListViewItem::nextSibling()..PPIf you need to move a list view item you can use takeItem() and insertItem(). Item's are deleted with delete; to delete all items use clear(). See the QListViewItem documentation for examples of traversal..PPThere are a variety of selection modes described in the QListView::SelectionMode documentation. The default is Single selection, which you can change using setSelectionMode()..PPBecause QListView offers multiple selection it must display keyboard focus and selection state separately. Therefore there are functions both to set the selection state of an item (setSelected()) and to select which item displays keyboard focus (setCurrentItem())..PPQListView emits two groups of signals; one group signals changes in selection/focus state and one indicates selection. The first group consists of selectionChanged() (applicable to all list views), selectionChanged( QListViewItem * ) (applicable only to Single selection list view), and currentChanged( QListViewItem * ). The second group consists of doubleClicked( QListViewItem * ), returnPressed( QListViewItem * ), rightButtonClicked( QListViewItem *, const QPoint&, int ), etc..PPIn Motif style, QListView deviates fairly strongly from the look and feel of the Motif hierarchical tree view. This is done mostly to provide a usable keyboard interface and to make the list view look better with a white background..PPIf selectionMode() is Single (the default) the user can select one item at a time, e.g. by clicking an item with the mouse, see QListView::SelectionMode for details..PPThe listview can be navigated either using the mouse or the keyboard. Clicking an \fB-\fR icon closes an item (hides its children) and clicking an \fB+\fR icon opens an item (shows its children). The keyboard controls are these: <center>.nf.TSl - l. Keypress Action Home Make the first item current and visible. End Make the last item current and visible. Page Up Make the item above the top visible item current and visible. Page Down Make the item below the bottom visible item current and visible. Up Arrow Make the item above the current item current and visible. Down Arrow Make the item below the current item current and visible. Left Arrow If the current item is closed ( Right Arrow If the current item is closed (.TE.fi</center>.PPIf the user starts typing letters with the focus in the listview an incremental search will occur. For example if the user types 'd' the current item will change to the first item that begins with the letter 'd'; if they then type 'a', the current item will change to the first item that begins with 'da', and so on. If no item begins with the letters they type the current item doesn't change..PP\fBWarning:\fR The list view assumes ownership of all list view items and will delete them when it does not need them any more..PP.ce 1.B "[Image Omitted]".PP.ce 1.B "[Image Omitted]".PPSee also QListViewItem, QCheckListItem, and Advanced Widgets..SS "Member Type Documentation".SH "QListView::RenameAction"This enum describes whether a rename operation is accepted if the rename editor loses focus without the user pressing Enter..TP\fCQListView::Accept\fR - Rename if Enter is pressed or focus is lost..TP\fCQListView::Reject\fR - Discard the rename operation if focus is lost (and Enter has not been pressed)..SH "QListView::ResizeMode"This enum describes how the header adjusts to resize events which affect the width of the listview..TP\fCQListView::NoColumn\fR - The columns do not get resized in resize events..TP\fCQListView::AllColumns\fR - All columns are resized equally to fit the width of the listview..TP\fCQListView::LastColumn\fR - The last columns is resized to fit the with of the listview..SH "QListView::SelectionMode"This enumerated type is used by QListView to indicate how it reacts to selection by the user..TP\fCQListView::Single\fR - When the user selects an item, any already-selected item becomes unselected, and the user cannot unselect the selected item. This means that the user can never clear the selection, even though the selection may be cleared by the application programmer using QListView::clearSelection()..TP\fCQListView::Multi\fR - When the user selects an item in the most ordinary way, the selection status of that item is toggled and the other items are left alone..TP\fCQListView::Extended\fR - When the user selects an item in the most ordinary way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. And if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item get selected or unselected, depending on the state of the clicked item. Also, multiple items can be selected by dragging the mouse while the left mouse button stays pressed..TP\fCQListView::NoSelection\fR - Items cannot be selected..PPIn other words, Single is a real single-selection list view, Multi a real multi-selection list view, Extended is a list view where users can select multiple items but usually want to select either just one or a range of contiguous items, and NoSelection is a list view where the user can look but not touch..SH "QListView::WidthMode"This enum type describes how the width of a column in the view changes..TP\fCQListView::Manual\fR - the column width does not change automatically..TP\fCQListView::Maximum\fR - the column is automatically sized according to the widths of all items in the column. (Note: The column never shrinks in this case.) This means the column is always resized to the width of the item with the largest width in the column..PPSee also setColumnWidth(), setColumnWidthMode(), and columnWidth()..SH MEMBER FUNCTION DOCUMENTATION.SH "QListView::QListView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )"Constructs a new empty list view called \fIname\fR with parent \fIparent\fR..PPPerformance is boosted by modifying the widget flags \fIf\fR so that only part of the QListViewItem children is redrawn. This may be unsuitable for custom QListViewItem classes, in which case WStaticContents and WRepaintNoErase should be cleared..PPSee also QWidget::clearWFlags() and Qt::WidgetFlags..SH "QListView::~QListView ()"Destroys the list view, deleting all its items, and frees up all allocated resources..SH "int QListView::addColumn ( const QString & label, int width = -1 )\fC [virtual]\fR"Adds a \fIwidth\fR pixels wide column with the column header \fIlabel\fR to this QListView, and returns the index of the new column..PPAll columns apart from the first one are inserted to the right of the existing ones..PPIf \fIwidth\fR is negative, the new column's WidthMode is set to Maximum instead of Manual..PPSee also setColumnText(), setColumnWidth(), and setColumnWidthMode()..PPExamples:.)l addressbook/centralwidget.cpp, checklists/checklists.cpp, dirview/main.cpp, fileiconview/mainwindow.cpp, listviews/listviews.cpp, and qdir/qdir.cpp..SH "int QListView::addColumn ( const QIconSet & iconset, const QString & label, int width = -1 )\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAdds a \fIwidth\fR pixels wide new column with the header \fIlabel\fR and \fIiconset\fR to this QListView, and returns the index of the column..PPIf \fIwidth\fR is negative, the new column's WidthMode is set to Maximum, and to Manual otherwise..PPSee also setColumnText(), setColumnWidth(), and setColumnWidthMode()..SH "bool QListView::allColumnsShowFocus () const"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -