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

📄 qtable.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 5 页
字号:
.br.ti -1c.BI "virtual void \fBsetLeftMargin\fR ( int m )".br.ti -1c.BI "virtual void \fBsetTopMargin\fR ( int m )".br.ti -1c.BI "virtual void \fBsetCurrentCell\fR ( int row, int col )".br.ti -1c.BI "void \fBclearSelection\fR ( bool repaint = TRUE )".br.ti -1c.BI "virtual void \fBsetColumnMovingEnabled\fR ( bool b )".br.ti -1c.BI "virtual void \fBsetRowMovingEnabled\fR ( bool b )".br.ti -1c.BI "virtual void \fBsetReadOnly\fR ( bool b )".br.ti -1c.BI "virtual void \fBsetRowReadOnly\fR ( int row, bool ro )".br.ti -1c.BI "virtual void \fBsetColumnReadOnly\fR ( int col, bool ro )".br.ti -1c.BI "virtual void \fBsetDragEnabled\fR ( bool b )".br.ti -1c.BI "bool \fBdragEnabled\fR () const".br.ti -1c.BI "virtual void \fBinsertRows\fR ( int row, int count = 1 )".br.ti -1c.BI "virtual void \fBinsertColumns\fR ( int col, int count = 1 )".br.ti -1c.BI "virtual void \fBremoveRow\fR ( int row )".br.ti -1c.BI "virtual void \fBremoveRows\fR ( const QMemArray<int> & rows )".br.ti -1c.BI "virtual void \fBremoveColumn\fR ( int col )".br.ti -1c.BI "virtual void \fBremoveColumns\fR ( const QMemArray<int> & cols )".br.ti -1c.BI "virtual void \fBeditCell\fR ( int row, int col, bool replace = FALSE )".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBcurrentChanged\fR ( int row, int col )".br.ti -1c.BI "void \fBclicked\fR ( int row, int col, int button, const QPoint & mousePos )".br.ti -1c.BI "void \fBdoubleClicked\fR ( int row, int col, int button, const QPoint & mousePos )".br.ti -1c.BI "void \fBpressed\fR ( int row, int col, int button, const QPoint & mousePos )".br.ti -1c.BI "void \fBselectionChanged\fR ()".br.ti -1c.BI "void \fBvalueChanged\fR ( int row, int col )".br.ti -1c.BI "void \fBcontextMenuRequested\fR ( int row, int col, const QPoint & pos )".br.ti -1c.BI "void \fBdropped\fR ( QDropEvent * e )".br.in -1c.SS "Properties".in +1c.ti -1c.BI "bool \fBcolumnMovingEnabled\fR - whether columns can be moved by the user".br.ti -1c.BI "FocusStyle \fBfocusStyle\fR - how the current (focus) cell is drawn".br.ti -1c.BI "int \fBnumCols\fR - the number of columns in the table".br.ti -1c.BI "int \fBnumRows\fR - the number of rows in the table".br.ti -1c.BI "bool \fBreadOnly\fR - whether the table is read-only".br.ti -1c.BI "bool \fBrowMovingEnabled\fR - whether rows can be moved by the user".br.ti -1c.BI "SelectionMode \fBselectionMode\fR - the current selection mode".br.ti -1c.BI "bool \fBshowGrid\fR - whether the table's grid is displayed".br.ti -1c.BI "bool \fBsorting\fR - whether a click on the header of a column sorts that column".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "enum \fBEditMode\fR { NotEditing, Editing, Replacing }".br.ti -1c.BI "virtual void \fBdrawContents\fR ( QPainter * p, int cx, int cy, int cw, int ch )".br.ti -1c.BI "void \fBsetEditMode\fR ( EditMode mode, int row, int col )".br.ti -1c.BI "virtual void \fBcontentsDragEnterEvent\fR ( QDragEnterEvent * e )".br.ti -1c.BI "virtual void \fBcontentsDragMoveEvent\fR ( QDragMoveEvent * e )".br.ti -1c.BI "virtual void \fBcontentsDragLeaveEvent\fR ( QDragLeaveEvent * e )".br.ti -1c.BI "virtual void \fBcontentsDropEvent\fR ( QDropEvent * e )".br.ti -1c.BI "virtual QDragObject * \fBdragObject\fR ()".br.ti -1c.BI "virtual void \fBstartDrag\fR ()".br.ti -1c.BI "virtual void \fBpaintEmptyArea\fR ( QPainter * p, int cx, int cy, int cw, int ch )".br.ti -1c.BI "virtual void \fBactivateNextCell\fR ()".br.ti -1c.BI "virtual QWidget * \fBcreateEditor\fR ( int row, int col, bool initFromCell ) const".br.ti -1c.BI "virtual void \fBsetCellContentFromEditor\fR ( int row, int col )".br.ti -1c.BI "virtual QWidget * \fBbeginEdit\fR ( int row, int col, bool replace )".br.ti -1c.BI "virtual void \fBendEdit\fR ( int row, int col, bool accept, bool replace )".br.ti -1c.BI "virtual void \fBresizeData\fR ( int len )".br.ti -1c.BI "virtual void \fBinsertWidget\fR ( int row, int col, QWidget * w )".br.ti -1c.BI "int \fBindexOf\fR ( int row, int col ) const".br.ti -1c.BI "bool \fBisEditing\fR () const".br.ti -1c.BI "EditMode \fBeditMode\fR () const".br.ti -1c.BI "int \fBcurrEditRow\fR () const".br.ti -1c.BI "int \fBcurrEditCol\fR () const".br.in -1c.SS "Protected Slots".in +1c.ti -1c.BI "virtual void \fBcolumnWidthChanged\fR ( int col )".br.ti -1c.BI "virtual void \fBrowHeightChanged\fR ( int row )".br.ti -1c.BI "virtual void \fBcolumnIndexChanged\fR ( int section, int fromIndex, int toIndex )".br.ti -1c.BI "virtual void \fBrowIndexChanged\fR ( int section, int fromIndex, int toIndex )".br.ti -1c.BI "virtual void \fBcolumnClicked\fR ( int col )".br.in -1c.SH DESCRIPTIONThe QTable class provides a flexible editable table widget..PPQTable is easy to use, although it does have a large API because of the comprehensive functionality that it provides. QTable includes functions for manipulating headers, rows and columns, cells and selections. QTable also provides in-place editing and drag and drop, as well as a useful set of signals. QTable efficiently supports very large tables, for example, tables one million by one million cells are perfectly possible. QTable is economical with memory, using none for unused cells..PP.nf.br    QTable *table = new QTable( 100, 250, this );.br    table->setPixmap( 3, 2, pix );.br    table->setText( 3, 2, "A pixmap" );.br.fi.PPThe first line constructs the table specifying its size in rows and columns. We then insert a pixmap and some text into the \fIsame\fR cell, with the pixmap appearing to the left of the text. By default a vertical header appears at the left of the table showing row numbers and a horizontal header appears at the top of the table showing column numbers. (The numbers displayed start at 1, although row and column numbers within QTable begin at 0.).PPIf you want to use mouse tracking call setMouseTracking( TRUE ) on the \fIviewport\fR; (see QScrollView)..SH "Headers"QTable supports a header column, e.g. to display row numbers, and a header row, e.g to display column titles. To set row or column labels use QHeader::setLabel() on the pointers returned by verticalHeader() and horizontalHeader() respectively. The vertical header is displayed within the table's left margin whose width is set with setLeftMargin(). The horizontal header is displayed within the table's top margin whose height is set with setTopMargin(). The table's grid can be switched off with setShowGrid(). If you want to hide a vertical header call hide(), and call setTopMargin( 0 ) so that the area the header would have occupied is reduced to zero size..PPHeader labels are indexed via their section numbers. Note that the default behavior of QHeader regarding section numbers is overriden for QTable. See the explanation below in Rows and Columns section in the discussion of moving columns and rows..SH "Rows and Columns"Row and column sizes are set with setRowHeight() and setColumnWidth(). If you want a row high enough to show the tallest item in its entirety, use adjustRow(). Similarly, to make a column wide enough to show the widest item use adjustColumn(). If you want the row height and column width to adjust automatically as the height and width of the table changes use setRowStretchable() and setColumnStretchable()..PPRows and columns can be hidden and shown with hideRow(), hideColumn(), showRow() and showColumn(). New rows and columns are inserted using insertRows() and insertColumns(). Additional rows and columns are added at the bottom (rows) or right (columns) if you set setNumRows() or setNumCols() to be larger than numRows() or numCols(). Existing rows and columns are removed with removeRow() and removeColumn(). Multiple rows and columns can be removed with removeRows() and removeColumns()..PPRows and columns can be set to be moveable, i.e. the user can drag them to reorder them, using rowMovingEnabled() and columnMovingEnabled(). For performance reasons, the default behavior of QHeader section numbers is overwritten by QTable. Currently in QTable, when a row or column is dragged and reordered, the section number is also changed to its new position. Therefore, there is no difference between the section and the index fields in QHeader. The QTable QHeader classes do not provide a mechanism for indexing independent of the user interface ordering..PPThe table can be sorted using sortColumn(). Users can sort a column by clicking its header if setSorting() is set to TRUE. Rows can be swapped with swapRows(), columns with swapColumns() and cells with swapCells()..PPFor editable tables (see setReadOnly()) you can set the read-only property of individual rows and columns with setRowReadOnly() and setColumnReadOnly(). (Whether a cell is editable or read-only depends on these settings and the cell's QTableItem::EditType.).PPThe row and column which have the focus are returned by currentRow() and currentColumn() respectively..PPAlthough many QTable functions operate in terms of rows and columns the indexOf() function returns a single integer identifying a particular cell..SH "Cells"All of a QTable's cells are empty when the table is constructed..PPThere are two approaches to populating the table's cells. The first and simplest approach is to use QTableItems or QTableItem subclasses. The second approach doesn't use QTableItems at all which is useful for very large sparse tables but requires you to reimplement a number of functions. We'll look at each approach in turn..PPTo put a string in a cell use setText(). This function will create a new QTableItem for the cell if one doesn't already exist, and displays the text in it. By default the table item's widget will be a QLineEdit. A pixmap may be put in a cell with setPixmap(), which also creates a table item if required. A cell may contain \fIboth\fR a pixmap and text; the pixmap is displayed to the left of the text. Another approach is to construct a QTableItem or QTableItem subclass, set its properties, then insert it into a cell with setItem()..PPIf you want cells which contain comboboxes use the QComboTableItem class. Similarly if you require cells containing checkboxes use the QCheckTableItem class. These table items look and behave just like the combobox or checkbox widgets but consume far less memory..PP.nf.br        for ( int j = 0; j < numRows; ++j ).br

⌨️ 快捷键说明

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