Q3TableItem Class Reference
|
Constant | Value | Description |
---|---|---|
Q3TableItem::Always | 3 | The cell always looks editable. |
Using 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.
If a cell with the edit type Always looks misaligned you could reimplement createEditor() for these items.
Constant | Value | Description |
---|---|---|
Q3TableItem::WhenCurrent | 2 | The cell looks editable only when it has keyboard focus (see Q3Table::setCurrentCell()). |
Q3TableItem::OnTyping | 1 | The cell looks editable only when the user types in it or double-clicks it. It resembles the WhenCurrent functionality but is, perhaps, nicer. |
The OnTyping edit type is the default when Q3TableItem objects are created by the convenience functions Q3Table::setText() and Q3Table::setPixmap().
Constant | Value | Description |
---|---|---|
Q3TableItem::Never | 0 | The cell is not editable. |
The cell is actually editable only if Q3Table::isRowReadOnly() is false for its row, Q3Table::isColumnReadOnly() is false for its column, and Q3Table::isReadOnly() is false.
Q3ComboTableItems 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. Q3ComboTableItems may be interacted with only if they are editable in accordance with their EditType as described above.
Creates a table item that is a child of table table with no text. The item has the EditType et.
The 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 Q3Table::setItem().
The table takes ownership of the table item, so a table item should not be inserted into more than one table at a time.
Creates a table item that is a child of table table with text text. The item has the EditType et.
The 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 Q3Table::setItem().
The table takes ownership of the table item, so a table item should not be inserted into more than one table at a time.
Creates a table item that is a child of table table with text text and pixmap p. The item has the EditType et.
The 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 Q3Table::setItem().
The table takes ownership of the table item, so a table item should not be inserted in more than one table at a time.
The destructor deletes this item and frees all allocated resources.
If 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.
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.
See also Qt::Alignment.
Returns the column where the table item is located. If the cell spans multiple columns, this function returns the left-most column.
Returns the column span of the table item, usually 1.
See also setSpan() and rowSpan().
This virtual function creates an editor which the user can interact with to edit the cell's contents. The default implementation creates a QLineEdit.
If the function returns 0, the cell is read-only.
The returned widget should preferably be invisible, ideally with Q3Table::viewport() as parent.
If you reimplement this function you'll almost certainly need to reimplement setContentFromEditor(), and may need to reimplement sizeHint().
See also Q3Table::createEditor(), setContentFromEditor(), Q3Table::viewport(), and setReplaceable().
Returns the table item's edit type.
This is set when the table item is constructed.
See also EditType and Q3TableItem().
Returns true if the table item is enabled; otherwise returns false.
See also setEnabled().
This function returns whether the contents of the cell may be replaced with the contents of another table item. Regardless of this setting, table items that span more than one cell may not have their contents replaced by another table item.
(This differs from EditType because EditType is concerned with whether the user is able to change the contents of a cell.)
See also setReplaceable() and EditType.
This virtual function returns the key that should be used for sorting. The default implementation returns the text() of the relevant item.
See also Q3Table::setSorting().
This virtual function is used to paint the contents of an item using the painter p in the rectangular area cr using the color group cg.
If selected is true the cell is displayed in a way that indicates that it is highlighted.
You don't usually need to use this function but if you want to draw custom content in a cell you will need to reimplement it.
The painter passed to this function is translated so that 0, 0 is the top-left corner of the item that is being painted.
Note that the painter is not clipped by default in order to get maximum efficiency. If you want clipping, use
p->setClipRect(table()->cellRect(row, col), QPainter::ClipPainter);
//... your drawing code
p->setClipping(false);
Returns the table item's pixmap or a null pixmap if no pixmap has been set.
See also setPixmap() and text().
Returns the row where the table item is located. If the cell spans multiple rows, this function returns the top-most row.
Returns the row span of the table item, usually 1.
See also setSpan() and colSpan().
Returns the Run Time Type Identification value for this table item which for Q3TableItems is 0.
When you create subclasses based on Q3TableItem make sure that each subclass returns a unique rtti() value. It is advisable to use values greater than 1000, preferably large random numbers, to allow for extensions to this class.
See also Q3CheckTableItem::rtti() and Q3ComboTableItem::rtti().
Sets column c as the table item's column. Usually you will not need to call this function.
If the cell spans multiple columns, this function sets the left-most column and retains the width of the multi-cell table item.
See also col(), setRow(), and colSpan().
Whenever the content of a cell has been edited by the editor w, Q3Table calls this virtual function to copy the new values into the Q3TableItem.
If you reimplement createEditor() and return something that is not a QLineEdit you will need to reimplement this function.
See also Q3Table::setCellContentFromEditor().
If b is true, the table item is enabled; if b is false the table item is disabled.
A disabled item doesn't respond to user interaction.
See also isEnabled().
Sets pixmap p to be this item's pixmap.
Note that setPixmap() does not update the cell the table item belongs to. Use Q3Table::updateCell() to repaint the cell's contents.
For Q3ComboTableItems and Q3CheckTableItems this function has no visible effect.
See also Q3Table::setPixmap(), pixmap(), and setText().
If b is true it is acceptable to replace the contents of the cell with the contents of another Q3TableItem. If b is false the contents of the cell may not be replaced by the contents of another table item. Table items that span more than one cell may not have their contents replaced by another table item.
(This differs from EditType because EditType is concerned with whether the user is able to change the contents of a cell.)
See also isReplaceable().
Sets row r as the table item's row. Usually you do not need to call this function.
If the cell spans multiple rows, this function sets the top row and retains the height of the multi-cell table item.
See also row(), setCol(), and rowSpan().
Changes the extent of the Q3TableItem so that it spans multiple cells covering rs rows and cs columns. The top left cell is the original cell.
Warning: This function only works if the item has already been inserted into the table using e.g. Q3Table::setItem(). This function also checks to make sure if rs and cs are within the bounds of the table and returns without changing the span if they are not. In addition swapping, inserting or removing rows and columns that cross Q3TableItems spanning more than one cell is not supported.
See also rowSpan() and colSpan().
Changes the table item's text to str.
Note that setText() does not update the cell the table item belongs to. Use Q3Table::updateCell() to repaint the cell's contents.
See also Q3Table::setText(), text(), setPixmap(), and Q3Table::updateCell().
If b is true, the cell's text will be wrapped over multiple lines, when necessary, to fit the width of the cell; otherwise the text will be written as a single line.
See also wordWrap(), Q3Table::adjustColumn(), and Q3Table::setColumnStretchable().
This virtual function returns the size a cell needs to show its entire content.
If you subclass Q3TableItem you will often need to reimplement this function.
Returns the Q3Table the table item belongs to.
See also Q3Table::setItem() and Q3TableItem().
Returns the text of the table item or an empty string if there is no text.
To ensure that the current value of the editor is returned, setContentFromEditor() is called:
This means that text() returns the original text value of the item if the editor is a line edit, until the user commits an edit (e.g. by pressing Enter or Tab) in which case the new text is returned. For other editors (e.g. a combobox) setContentFromEditor() is always called so the currently display value is the one returned.
See also setText() and pixmap().
Returns true if word wrap is enabled for the cell; otherwise returns false.
See also setWordWrap().
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.5.2 |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |