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

📄 qtable.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 3 页
字号:
.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.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBdrawContents\fR ( QPainter * " "p" ", int " "cx" ", int " "cy" ", int " "cw" ", int ch ) ".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.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 " "s" ", int " "oi" ", int ni ) ".br.ti -1c.BI "virtual void \fBrowIndexChanged\fR ( int " "s" ", int " "oi" ", int ni ) ".br.ti -1c.BI "virtual void \fBcolumnClicked\fR ( int col ) ".br.in -1c.SS "Properties".nf.TSl l l l l- - - - -l l l l l.Type	Name	READ	WRITE	Optionsint	numRows	numRows	setNumRowsint	numCols	numCols	setNumColsbool	showGrid	showGrid	setShowGridbool	rowMovingEnabled	rowMovingEnabled	setRowMovingEnabledbool	columnMovingEnabled	columnMovingEnabled	setColumnMovingEnabled.TE.fi.SH DESCRIPTIONA flexible and editable table widget..PPQTable has been designed to use no more memory than strictly needed. Thus, for an empty cell, no memory at all is allocated. In order to add data, create a QTableItem and fill it using setItem(). With QTableItem::setText() and QTableItem::setPixmap(), convenient functions for setting table text and pixmaps are provided. To clear a cell use clearCell()..PPQTable supports various methods for selecting cells, both with keyboard and mouse, thus for example range selection or column and row selection via appropriate header cells. You can add and remove selections using addSelection() and removeSelection(), resp., and gather information about current selections by means of numSelections(), selection(), and currentChanged()..PPQTable also offers an API for sorting columns. See setSorting(), sortColumn() and QTableItem::key() for details..PPCell editing can be done in two different ways: Either you offer an edit widget the user can use to enter data that should replace the current content, or you provide him or her with an editor to change the data stored in the cell. If you won't allow the content of a cell to be replaced, however make it possible to edit the current data, simply set QTableItem::isReplaceable() to FALSE..PPWhen a user starts typing text in-place editing (replacing) for the current cell is invoked. Additionally, in-place editing (editing) starts as soon as he or she double-clicks a cell. Sometimes, however, it is required that a cell always shows an editor, that the editor shows off as soon as the relevant cell receives the focus, or that the item shouldn't be edited at all. This edit type has to be specified in the constructor of a QTableItem..PPIn-place editing is invoked by beginEdit(). This function creates the editor widget for the required cell (see createEditor() for detailed information) and shows it at the appropriate location..PPAs soon as the user finishes editing endEdit() is called. Have a look at the endEdit() documentation for further information e.g. on how content is transferred from the editor to the item or how the editor is destroyed..PPIn-place editing is implemented in an abstract way to make sure custom edit widgets for certain cells or cell types can be written easily. To obtain this it is possible to place widgets in cells. See setCellWidget(), clearCellWidget() and cellWidget() for further details..PPIn order to prevent a cell not containing a QTableItem from being edited, you have to reimplement createEditor(). This function should return 0 for cells that must be not edited at all..PPIt is possible to use QTable without QTableItems. However, as the default implementation of QTable's in-place editing uses QTableItems, you will have to reimplement createEditor() and setCellContentFromEditor() to get in-place editing without QTableItems. The documentation of these two functions explains the details you need to know for that matter..PPIn order to draw custom content in a cell you have to implement your own subclass of QTableItem and reimplement the QTableItem::paint() method..PPIf your application stores its data already in a way that allocating a QTableItem for each data containing cell seems inappropriate, you can reimplement QTable::paintCell() and draw the contents directly. You should also reimplement QTable::paintCell() if you wish to change the alignment of your items in the QTable..PPUnless you reimplement them this approach will however prevent you from using functions like setText() etc. Remember that in this case, repainting the cells using updateCell() after each change made is necessary. To make sure you don't waste memory, read the documentation of resizeData()..SS "Member Type Documentation".SH "QTable::SelectionMode".TP\fCNoSelection\fR - No cell can be selected by the user..TP\fCSingle\fR - The user may select one range of cells only..TP\fCMulti\fR - Multi-range selections are possible..SH MEMBER FUNCTION DOCUMENTATION.SH "QTable::QTable ( QWidget * parent = 0, const char * name = 0 )"Constructs a table of 10 * 10 cells..PPPerformance is boosted by modifying the widget flags so that only part of the QTableItem children is redrawn. This may be unsuitable for custom QTableItem classes, in which case \fCWNorthWestGravity\fR and \fCWRepaintNoErase\fR should be cleared..PPSee also QWidget::clearWFlags() and Qt::WidgetFlags..SH "QTable::QTable ( int numRows, int numCols, QWidget * parent = 0, const char * name = 0 )"Constructs a table with a range of \fInumRows\fR * \fInumCols\fR cells..PPPerformance is boosted by modifying the widget flags so that only part of the QTableItem children is redrawn. This may be unsuitable for custom QTableItem classes, in which case the widget flags should be reset using QWidget::setWFlags()..SH "QTable::~QTable ()"Destructor..SH "void QTable::activateNextCell () \fC[virtual protected]\fR"This is called to activate the next cell if in-place editing was finished by pressing the Return key..PPIf you want a different behaviour then going from top to bottom, reimplement this function..SH "int QTable::addSelection ( const QTableSelection & s ) \fC[virtual]\fR"Adds a selection described by \fIs\fR to the table and returns its number or -1 if the selection is invalid. Don't forget to call QTableSelection::init() and QTableSelection::expandTo() to make it valid (see also QTableSelection::isActive())..SH "void QTable::adjustColumn ( int col ) \fC[virtual slot]\fR"Resizes the column \fIcol\fR to be exactly wide enough so that the whole contents is visible..SH "void QTable::adjustRow ( int row ) \fC[virtual slot]\fR"Resizes the row \fIrow\fR to be exactly high enough so that the whole contents is visible..SH "QWidget * QTable::beginEdit ( int row, int col, bool replace ) \fC[virtual protected]\fR"This function is called to start in-place editing of the cell \fIrow, col.\fR If \fIreplace\fR is TRUE the content of this cell will be replaced by the content of the editor later, else the current content of that cell (if existing) will be edited by the editor..PPThis function calls createEditor() to get the editor which should be used for editing the cell and after that setCellWidget() to set this editor as the widget of that cell..PPSee also createEditor(), setCellWidget() and endEdit()..SH "QRect QTable::cellGeometry ( int row, int col ) const \fC[virtual]\fR"Returns the bounding rect of the cell \fIrow, col\fR in contents coordinates..SH "QWidget * QTable::cellWidget ( int row, int col ) const \fC[virtual]\fR"Returns the widget which has been set to the cell \fIrow, col\fR of 0 if there is no widget..SH "void QTable::clearCell ( int row, int col ) \fC[virtual]\fR"Removes the QTableItem in position \fIrow, col.\fR.SH "void QTable::clearCellWidget ( int row, int col ) \fC[virtual]\fR"Removes the widget (if there is any) which is set for the cell \fIrow, col.\fR.SH "void QTable::clearSelection ( bool repaint = TRUE ) \fC[slot]\fR"Clears all selections..SH "void QTable::clicked ( int row, int col, int button, const QPoint & mousePos ) \fC[signal]\fR"This signal is emitted as soon as a user clicks on \fIrow\fR and \fIcol\fR using mousebutton \fIbutton.\fR The actual mouse position is passed as \fImousePos.\fR.SH "int QTable::columnAt ( int pos ) const \fC[virtual]\fR"Returns the column which is at \fIpos. pos\fR has to be given in contents coordinates..SH "void QTable::columnClicked ( int col ) \fC[virtual protected slot]\fR"This function is called when the column \fCcol\fR has been clicked. The default implementation sorts this column if sorting() is TRUE..SH "void QTable::columnIndexChanged ( int, int, int ) \fC[virtual protected slot]\fR"This function is called if the order of the columns has been changed. If you want to change the order programmatically, call swapRows() or swapColumns()..SH "bool QTable::columnMovingEnabled () const"Returns whether columns can be moved by the user..SH "int QTable::columnPos ( int col ) const \fC[virtual]\fR"Returns the x-position of the column \fIcol\fR in contents coordinates..SH "int QTable::columnWidth ( int col ) const \fC[virtual]\fR"Returns the width of the column \fIcol.\fR.SH "void QTable::columnWidthChanged ( int col ) \fC[virtual protected slot]\fR"This function should be called whenever the column width of \fIcol\fR has been changed. It will then rearrange the content appropriately..SH "void QTable::contentsMouseDoubleClickEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QScrollView..SH "void QTable::contentsMouseMoveEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QScrollView..SH "void QTable::contentsMousePressEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QScrollView..SH "void QTable::contentsMouseReleaseEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QScrollView..SH "QWidget * QTable::createEditor ( int row, int col, bool initFromCell ) const \fC[virtual protected]\fR"This function returns a widget which should be used as editor for the cell \fIrow, col.\fR If \fIinitFromCell\fR is TRUE, the editor is used to edit the current content of the cell (so the editor widget should be initialized with that content). Otherwise the content of this cell will be replaced by a new content which the user will enter into the widget which this function should create..PPThe default implementation looks if there exists a QTableItem for the cell. If this is the case and \fIinitFromCell\fR is TRUE or QTableItem::isReplaceable() of the item is FALSE, the item of that cell is asked to create the editor (using QTableItem::createEditor))..PPIf this is not the case, a QLineEdit is created as editor..PPSo if you want to create your own editor for certain cells, implement your own QTableItem and reimplement QTableItem::createEditor(). If you want to use a different editor than a QLineEdit as default editor, reimplement this function and use a code like.PP.nf.br    QTableItem *i = item( row, col );.br    if ( initFromCell || i && !i->isReplaceable() ).br        return QTable::createEditor( row, col, initFromCell );.br    else.br        return ...(create your editor).fi.PPSo normally you do not need to reimplement this function. But if you want e.g. work without QTableItems, you will reimplement this function to create the correct editor for the cells..PPThe ownership of the editor widget is transferred to the caller..PPReturning 0 here means that the cell is not editable..PPSee also QTableItem::createEditor()..SH "void QTable::currentChanged ( int row, int col ) \fC[signal]\fR"This signal is emitted if the current cell has been changed to \fIrow, col.\fR.SH "int QTable::currentColumn () const"Returns the current column..SH "int QTable::currentRow () const"Returns the current row..SH "int QTable::currentSelection () const \fC[virtual]\fR"Returns the number of the current selection or -1 if there is none..SH "void QTable::doubleClicked ( int row, int col, int button, const QPoint & mousePos ) \fC[signal]\fR"A double-click with \fIbutton\fR emits this signal, where \fIrow\fR and \fIcol\fR denote the position of the cell. The actual mouse position is passed as \fImousePos.\fR.SH "void QTable::drawContents ( QPainter * p, int cx, int cy, int cw, int ch ) \fC[virtual protected]\fR"Draws the table contents on the painter \fIp.\fR The function is optimized to exclusively draw the cells inside the relevant clipping rectangle \fIcx, cy, cw, ch.\fR.PPAdditionally, drawContents() highlights the current cell..PPReimplemented from QScrollView..SH "void QTable::endEdit ( int row, int col, bool accept, bool replace ) \fC[virtual protected]\fR"This function is called if in-place editing of the cell \fIrow, col\fR has to be ended. If \fIaccept\fR is TRUE the content of the editor of this cell has to be transferred to the cell. If \fIreplace\fR is TRUE the current content of that cell should be replaced by the content of the editor (this means removing the current QTableItem of the cell and creating a new one for the cell), else (if possible) the content of the editor should just be set to the existing QTableItem of this cell..PPSo, if the cell contents should be replaced or if no QTableItem exists for the cell yet, setCellContentFromEditor() is called, else QTableItem::setContentFromEditor() is called on the QTableItem of the cell.

⌨️ 快捷键说明

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