📄 qtableview.3qt
字号:
.TH QTableView 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTableView \- This is an abstract base class for implementing tables.SH SYNOPSIS.br.PP\fC#include <qtableview.h>\fR.PPInherits QFrame..PPInherited by QMultiLineEdit..PP.SS "Public Members".in +1c.ti -1c.BI "virtual void \fBsetBackgroundColor\fR ( const QColor & )".br.ti -1c.BI "virtual void \fBsetPalette\fR ( const QPalette & )".br.ti -1c.BI "virtual void \fBshow\fR ()".br.ti -1c.BI "void \fBrepaint\fR ( bool " "erase" "=TRUE )".br.ti -1c.BI "void \fBrepaint\fR ( int " "x" ", int " "y" ", int " "w" ", int " "h" ", bool " "erase" "=TRUE )".br.ti -1c.BI "void \fBrepaint\fR ( const QRect &, bool " "erase" "=TRUE )".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "\fBQTableView\fR ( QWidget * " "parent" "=0, const char * " "name" "=0, WFlags " "f" "=0 )".br.ti -1c.BI "\fB~QTableView\fR ()".br.ti -1c.BI "int \fBnumRows\fR () const".br.ti -1c.BI "virtual void \fBsetNumRows\fR ( int )".br.ti -1c.BI "int \fBnumCols\fR () const".br.ti -1c.BI "virtual void \fBsetNumCols\fR ( int )".br.ti -1c.BI "int \fBtopCell\fR () const".br.ti -1c.BI "virtual void \fBsetTopCell\fR ( int row )".br.ti -1c.BI "int \fBleftCell\fR () const".br.ti -1c.BI "virtual void \fBsetLeftCell\fR ( int col )".br.ti -1c.BI "virtual void \fBsetTopLeftCell\fR ( int " "row" ", int col )".br.ti -1c.BI "int \fBxOffset\fR () const".br.ti -1c.BI "virtual void \fBsetXOffset\fR ( int )".br.ti -1c.BI "int \fByOffset\fR () const".br.ti -1c.BI "virtual void \fBsetYOffset\fR ( int )".br.ti -1c.BI "virtual void \fBsetOffset\fR ( int " "x" ", int " "y" ", bool " "updateScrBars" " = TRUE )".br.ti -1c.BI "virtual int \fBcellWidth\fR ( int col )".br.ti -1c.BI "virtual int \fBcellHeight\fR ( int row )".br.ti -1c.BI "int \fBcellWidth\fR () const".br.ti -1c.BI "int \fBcellHeight\fR () const".br.ti -1c.BI "virtual void \fBsetCellWidth\fR ( int )".br.ti -1c.BI "virtual void \fBsetCellHeight\fR ( int )".br.ti -1c.BI "virtual int \fBtotalWidth\fR ()".br.ti -1c.BI "virtual int \fBtotalHeight\fR ()".br.ti -1c.BI "uint \fBtableFlags\fR () const".br.ti -1c.BI "bool \fBtestTableFlags\fR ( uint f ) const".br.ti -1c.BI "virtual void \fBsetTableFlags\fR ( uint f )".br.ti -1c.BI "void \fBclearTableFlags\fR ( uint f = ~0 )".br.ti -1c.BI "bool \fBautoUpdate\fR () const".br.ti -1c.BI "virtual void \fBsetAutoUpdate\fR ( bool )".br.ti -1c.BI "void \fBupdateCell\fR ( int " "row" ", int " "column" ", bool " "erase" "=TRUE )".br.ti -1c.BI "QRect \fBcellUpdateRect\fR () const".br.ti -1c.BI "QRect \fBviewRect\fR () const".br.ti -1c.BI "int \fBlastRowVisible\fR () const".br.ti -1c.BI "int \fBlastColVisible\fR () const".br.ti -1c.BI "bool \fBrowIsVisible\fR ( int row ) const".br.ti -1c.BI "bool \fBcolIsVisible\fR ( int col ) const".br.ti -1c.BI "QScrollBar* \fBverticalScrollBar\fR () const".br.ti -1c.BI "QScrollBar* \fBhorizontalScrollBar\fR () const".br.ti -1c.BI "virtual void \fBpaintCell\fR ( QPainter *, int " "row" ", int col )".br.ti -1c.BI "virtual void \fBsetupPainter\fR ( QPainter * )".br.ti -1c.BI "virtual void \fBpaintEvent\fR ( QPaintEvent * )".br.ti -1c.BI "virtual void \fBresizeEvent\fR ( QResizeEvent * )".br.ti -1c.BI "int \fBfindRow\fR ( int yPos ) const".br.ti -1c.BI "int \fBfindCol\fR ( int xPos ) const".br.ti -1c.BI "bool \fBrowYPos\fR ( int " "row" ", int * yPos ) const".br.ti -1c.BI "bool \fBcolXPos\fR ( int " "col" ", int * xPos ) const".br.ti -1c.BI "int \fBmaxXOffset\fR ()".br.ti -1c.BI "int \fBmaxYOffset\fR ()".br.ti -1c.BI "int \fBmaxColOffset\fR ()".br.ti -1c.BI "int \fBmaxRowOffset\fR ()".br.ti -1c.BI "int \fBminViewX\fR () const".br.ti -1c.BI "int \fBminViewY\fR () const".br.ti -1c.BI "int \fBmaxViewX\fR () const".br.ti -1c.BI "int \fBmaxViewY\fR () const".br.ti -1c.BI "int \fBviewWidth\fR () const".br.ti -1c.BI "int \fBviewHeight\fR () const".br.ti -1c.BI "void \fBscroll\fR ( int " "xPixels" ", int yPixels )".br.ti -1c.BI "void \fBupdateScrollBars\fR ()".br.ti -1c.BI "void \fBupdateTableSize\fR ()".br.in -1c.SH DESCRIPTIONThis is an abstract base class for implementing tables.PPA table view consists of a number of abstract cells organized in rows and columns and a visible part called a view. The cells are identified with a row index and a column index. The top left cell is in row 0, column 0..PPThe behavior of the widget can be finely tuned using setTableFlags(); a typical subclass will consist of little more than a call to setTableFlags(), some table content manipulation, and an implementation of paintCell(). Subclasses that need cells with variable width or height must reimplement cellHeight() and/or cellWidth(). Use updateTableSize() to tell QTableView when the width or height has changed..PPWhen you read this documentation, it is important to understand the distinctions between the four pixel coordinate systems involved..IP 1The \fIcell\fR coordinates. (0,0) is the top left corner of a cell. This is used by functions such as paintCell()..IP 2The \fItable\fR coordinates. (0,0) is the top left corner of the cell at row 0 and column 0. These coordinates are absolute; that is, they are independent of what part of the table is visible at the moment. This is used by functions such as setXOffset() or maxYOffset()..IP 3The \fIwidget\fR coordinates. (0,0) is the top left corner of the widget, \fIincluding\fR the frame. This is used by functions such as repaint()..IP 4The \fIview\fR coordinates. (0,0) is the top left corner of the view, \fIexcluding\fR the frame. This is the least-used coordinate system, used by functions such as viewWidth(). .PPIt is rather unfortunate that we have to use four different coordinate systems, but if we were to provide a flexible and powerful base class, there wasn't any way around it..PPNote: The row,column indices are always given in that order, i.e. first the vertical (row), then the horizontal (column). This is the opposite order of all pixel operations, which take first the horizontal (x), then the vertical (y)..PP<img src=qtablevw-m.png> <img src=qtablevw-w.png>.PP\fBWarning:\fR the functions setNumRows(), setNumCols(), setCellHeight(), setCellWidth(), setTableFlags() and clearTableFlags() may cause virtual functions like cellWidth() and cellHeight() to be called, even if autoUpdate() is FALSE. This may cause errors if relevant state variables are not initialized..PP\fBWarning:\fR Experience has shown that use of this widget tends to bring more bugs than expected, and our analysis indicates that widget's very flexibility is the problem. If QScrollView or QListBox can easily be made to do the job you need, we recommend subclassing those widgets rather than QTableView..PPSee also: QScrollView and GUI Design Handbook: Table.SH MEMBER FUNCTION DOCUMENTATION.SH "QTableView::QTableView ( QWidget * parent=0, const char * name=0, WFlags f=0 ) \fC[protected]\fR"Constructs a table view. All the arguments are passed to the QFrame constructor..PPThe table flags are all cleared (set to zero). Set \fCTbl_autoVScrollBar\fR or \fCTbl_autoHScrollBar\fR to get automatic scroll bars and \fCTbl_clipCellPainting\fR to get safe clipping..PPThe cell height and cell width are set to 0..PPFrame line shapes (QFrame::HLink and QFrame::VLine) are disallowed, see QFrame::setFrameStyle()..PPNote that the \fIf\fR argument is \fInot\fR table flags but rather widget flags..SH "QTableView::~QTableView () \fC[protected]\fR"Destroys the table view..SH "bool QTableView::autoUpdate () const \fC[protected]\fR"Returns TRUE if the view updates itself automatically whenever it is changed in some way..PPSee also: setAutoUpdate()..SH "int QTableView::cellHeight () const \fC[protected]\fR"Returns the row height, in pixels. Returns 0 if the rows have variable heights..PPSee also: setCellHeight() and cellWidth()..SH "int QTableView::cellHeight ( int ) \fC[virtual protected]\fR"Returns the height of row \fIrow,\fR in pixels..PPThis function is virtual and must be reimplemented by subclasses that have variable cell heights. Note that if the total table height changes, updateTableSize() must be called..PPSee also: setCellHeight(), cellWidth() and totalHeight()..SH "QRect QTableView::cellUpdateRect () const \fC[protected]\fR"This function should only be called from the paintCell() function in subclasses. It returns the portion of a cell that actually needs to be updated, in \fIcell\fR coordinates. This is only useful for non-trivial paintCell()..SH "int QTableView::cellWidth () const \fC[protected]\fR"Returns the column width, in pixels. Returns 0 if the columns have variable widths..PPSee also: setCellWidth() and cellHeight()..SH "int QTableView::cellWidth ( int ) \fC[virtual protected]\fR"Returns the width of column \fIcol,\fR in pixels..PPThis function is virtual and must be reimplemented by subclasses that have variable cell widths. Note that if the total table width changes, updateTableSize() must be called..PPSee also: setCellWidth(), cellHeight(), totalWidth() and updateTableSize()..SH "void QTableView::clearTableFlags ( uint f = ~0 ) \fC[protected]\fR"Clears the table flags that are set in \fIf.\fR.PPExample (clears a single flag):.PP.nf.br clearTableFlags( Tbl_snapToGrid );.fi.PPThe default argument clears all flags..PPSee also: setTableFlags(), testTableFlags() and tableFlags()..SH "bool QTableView::colIsVisible ( int col ) const \fC[protected]\fR"Returns TRUE if \fIcol\fR is at least partially visible..PPSee also: rowIsVisible()..SH "bool QTableView::colXPos ( int col, int * xPos ) const \fC[protected]\fR"Computes the position in the widget of column \fIcolumn.\fR.PPReturns TRUE and stores the result in \fI*xPos\fR (in \fIwidget\fR coordinates) if the column is visible. Returns FALSE and does not modify \fI*xPos\fR if \fIcol\fR is invisible or invalid..PPSee also: rowYPos() and findCol()..SH "int QTableView::findCol ( int xPos ) const \fC[protected]\fR"Returns the index of the column at position \fIxPos,\fR where \fIxPos\fR is in \fIwidget\fR coordinates. Returns -1 if \fIxPos\fR is outside the valid range..PPSee also: findRow() and colXPos()..SH "int QTableView::findRow ( int yPos ) const \fC[protected]\fR"Returns the index of the row at position \fIyPos,\fR where \fIyPos\fR is in \fIwidget\fR coordinates. Returns -1 if \fIyPos\fR is outside the valid range..PPSee also: findCol() and rowYPos()..SH "QScrollBar * QTableView::horizontalScrollBar () const \fC[protected]\fR"Returns a pointer to the horizontal scroll bar, mainly so you can connect() to its signals. Note that the scroll bar works in pixel values, use findCol() to translate to cell numbers..SH "int QTableView::lastColVisible () const \fC[protected]\fR"Returns the index of the last (right) column in the view. The index of the first column is 0..PPIf no columns are visible it returns -1. This can happen if the view is too narrow for the first column and Tbl_cutCellsH is set.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -