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

📄 qtableitem.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QTableItem 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTableItem \- The cell content for QTable cells.PP\fC#include <qtable.h>\fR.PPInherits Qt..PPInherited by QComboTableItem and QCheckTableItem..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBEditType\fR { Never, OnTyping, WhenCurrent, Always }".br.ti -1c.BI "\fBQTableItem\fR ( QTable * table, EditType et, const QString & text )".br.ti -1c.BI "\fBQTableItem\fR ( QTable * table, EditType et, const QString & text, const QPixmap & p )".br.ti -1c.BI "virtual \fB~QTableItem\fR ()".br.ti -1c.BI "virtual QPixmap \fBpixmap\fR () const".br.ti -1c.BI "virtual QString \fBtext\fR () const".br.ti -1c.BI "virtual void \fBsetPixmap\fR ( const QPixmap & p )".br.ti -1c.BI "virtual void \fBsetText\fR ( const QString & str )".br.ti -1c.BI "QTable * \fBtable\fR () const".br.ti -1c.BI "virtual int \fBalignment\fR () const".br.ti -1c.BI "virtual void \fBsetWordWrap\fR ( bool b )".br.ti -1c.BI "bool \fBwordWrap\fR () const".br.ti -1c.BI "EditType \fBeditType\fR () const".br.ti -1c.BI "virtual QWidget * \fBcreateEditor\fR () const".br.ti -1c.BI "virtual void \fBsetContentFromEditor\fR ( QWidget * w )".br.ti -1c.BI "virtual void \fBsetReplaceable\fR ( bool b )".br.ti -1c.BI "bool \fBisReplaceable\fR () const".br.ti -1c.BI "virtual QString \fBkey\fR () const".br.ti -1c.BI "virtual QSize \fBsizeHint\fR () const".br.ti -1c.BI "virtual void \fBsetSpan\fR ( int rs, int cs )".br.ti -1c.BI "int \fBrowSpan\fR () const".br.ti -1c.BI "int \fBcolSpan\fR () const".br.ti -1c.BI "virtual void \fBsetRow\fR ( int r )".br.ti -1c.BI "virtual void \fBsetCol\fR ( int c )".br.ti -1c.BI "int \fBrow\fR () const".br.ti -1c.BI "int \fBcol\fR () const".br.ti -1c.BI "virtual void \fBpaint\fR ( QPainter * p, const QColorGroup & cg, const QRect & cr, bool selected )".br.ti -1c.BI "virtual void \fBsetEnabled\fR ( bool b )".br.ti -1c.BI "bool \fBisEnabled\fR () const".br.ti -1c.BI "virtual int \fBrtti\fR () const".br.in -1c.SH DESCRIPTIONThe QTableItem class provides the cell content for QTable cells..PPFor many applications QTableItems are ideal for presenting and editing the contents of table cells. In situations where you need to create very large tables you may prefer an alternative approach to using QTableItems: see the notes on large tables..PPA QTableItem contains a cell's data, by default, a string and a pixmap. The table item also holds the cell's display size and how the data should be aligned. The table item specifies the cell's EditType and the editor used for in-place editing (by default a QLineEdit). If you want checkboxes use QCheckTableItem, and if you want comboboxes use QComboTableItem. The EditType (set in the constructor) determines whether the cell's contents may be edited; setReplaceable() sets whether the cell's contents may be replaced by another cell's contents..PPIf a pixmap is specified it is displayed to the left of any text. You can change the text or pixmap with setText() and setPixmap() respectively. For text you can use setWordWrap(). A table item's alignment is set in the constructor..PPReimplement createEditor() and setContentFromEditor() if you want to use your own widget instead of a QLineEdit for editing cell contents. Reimplement paint() if you want to display custom content. If you want a checkbox table item use QCheckTableItem, and if you want a combo table item use QComboTableItem..PPWhen sorting table items the key() function is used; by default this returns the table item's text(). Reimplement key() to customize how your table items will sort..PPTable items are inserted into a table using QTable::setItem(). If you insert an item into a cell that already contains a table item the original item will be deleted..PPExample:.PP.nf.br    for ( int row = 0; row < table->numRows(); row++ ) {.br        for ( int col = 0; col < table->numCols(); col++ ) {.br            table->setItem( row, col,.br                new QTableItem( table, WhenCurrent, QString::number( row * col ) ) );.br        }.br    }.br.fi.PPYou can move a table item from one cell to another, in the same or a different table, using QTable::takeItem() and QTable::setItem() but see also QTable::swapCells()..PPTable items can be deleted with delete in the standard way; the table and cell will be updated accordingly..PPSee also Advanced Widgets..SS "Member Type Documentation".SH "QTableItem::EditType"This enum is used to define whether a cell is editable or read-only (in conjunction with other settings), and how the cell should be displayed..TP\fCQTableItem::Always\fR - The cell always \fIlooks\fR editable..PPUsing this EditType ensures that the editor created with createEditor() (by default a QLineEdit) is always visible. This has implications for the alignment of the content: the default editor aligns everything (even numbers) to the left whilst numerical values in the cell are by default aligned to the right..PPIf a cell with the edit type Always looks misaligned you could reimplement createEditor() for these items..TP\fCQTableItem::WhenCurrent\fR - The cell \fIlooks\fR editable only when it has keyboard focus (see QTable::setCurrentCell())..TP\fCQTableItem::OnTyping\fR - The cell \fIlooks\fR editable only when the user types in it or double-clicks it. It resembles the WhenCurrent functionality but is, perhaps, nicer..PPThe OnTyping edit type is the default when QTableItem objects are created by the convenience functions QTable::setText() and QTable::setPixmap()..TP\fCQTableItem::Never\fR - The cell is not editable..PPThe cell is actually editable only if QTable::isRowReadOnly() is FALSE for its row, QTable::isColumnReadOnly() is FALSE for its column, and QTable::isReadOnly() is FALSE..PPQComboTableItems have an isEditable() property. This property is used to indicate whether the user may enter their own text or are restricted to choosing one of the choices in the list. QComboTableItems may be interacted with only if they are editable in accordance with their EditType as described above..PP.SH MEMBER FUNCTION DOCUMENTATION.SH "QTableItem::QTableItem ( QTable * table, EditType et, const QString & text )"Creates a child item of table \fItable\fR with text \fItext\fR. The item has the EditType \fIet\fR..PPThe table item will use a QLineEdit for its editor, will not word-wrap and will occupy a single cell. Insert the table item into a table with QTable::setItem()..PPThe table takes ownership of the table item, so a table item should not be inserted into more than one table at a time..SH "QTableItem::QTableItem ( QTable * table, EditType et, const QString & text, const QPixmap & p )"Creates a child item of table \fItable\fR with text \fItext\fR and pixmap \fIp\fR. The item has the EditType \fIet\fR..PPThe table item will display the pixmap to the left of the text. It will use a QLineEdit for editing the text, will not word-wrap and will occupy a single cell. Insert the table item into a table with QTable::setItem()..PPThe table takes ownership of the table item, so a table item should not be inserted in more than one table at a time..SH "QTableItem::~QTableItem ()\fC [virtual]\fR"The destructor deletes this item and frees all allocated resources..PPIf the table item is in a table (i.e. was inserted with setItem()), it will be removed from the table and the cell it occupied..SH "int QTableItem::alignment () const\fC [virtual]\fR"The alignment function returns how the text contents of the cell are aligned when drawn. The default implementation aligns numbers to the right and any other text to the left..PPSee also Qt::AlignmentFlags..SH "int QTableItem::col () const"Returns the column where the table item is located. If the cell spans multiple columns, this function returns the left-most column..PPSee also row() and setCol()..SH "int QTableItem::colSpan () const"Returns the column span of the table item, usually 1..PPSee also setSpan() and rowSpan().

⌨️ 快捷键说明

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