Eneboo - Documentación para desarrolladores
|
The QCheckTableItem class provides checkboxes in QTables.table. Más...
#include <qtable.h>
Métodos públicos | |
QCheckTableItem (QTable *table, const QString &txt) | |
void | setText (const QString &t) |
virtual QWidget * | createEditor () const |
virtual void | setContentFromEditor (QWidget *w) |
virtual void | paint (QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected) |
virtual void | setChecked (bool b) |
bool | isChecked () const |
int | rtti () const |
QSize | sizeHint () const |
QCheckTableItem (QTable *table, const QString &txt) | |
void | setText (const QString &t) |
virtual QWidget * | createEditor () const |
virtual void | setContentFromEditor (QWidget *w) |
virtual void | paint (QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected) |
virtual void | setChecked (bool b) |
bool | isChecked () const |
int | rtti () const |
QSize | sizeHint () const |
Atributos públicos estáticos | |
static int | RTTI = 2 |
The QCheckTableItem class provides checkboxes in QTables.
table.
A QCheckTableItem is a table item which looks and behaves like a checkbox. The advantage of using QCheckTableItems rather than real checkboxes is that a QCheckTableItem uses far less resources than a real checkbox would in a {QTable}. When the cell has the focus it displays a real checkbox which the user can interact with. When the cell does not have the focus the cell looks like a checkbox. Pixmaps may not be used in QCheckTableItems.
QCheckTableItem items have the edit type WhenCurrent
(see {EditType}).
To change the checkbox's label use setText(). The checkbox can be checked and unchecked with setChecked() and its state retrieved using isChecked().
To populate a table cell with a QCheckTableItem use QTable::setItem().
QCheckTableItems can be distinguished from {QTableItem}s and {QComboTableItem}s using their Run Time Type Identification (rtti) value.
qtableitems.png Table Items
Creates a QCheckTableItem with an {EditType} of WhenCurrent
as a child of table. The checkbox is initially unchecked and its label is set to the string txt.
QWidget * QCheckTableItem::createEditor | ( | ) | const [virtual] |
Reimplementado de QTableItem.
virtual QWidget* QCheckTableItem::createEditor | ( | ) | const [virtual] |
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 QTable::viewport() as parent.
If you reimplement this function you'll almost certainly need to reimplement setContentFromEditor(), and may need to reimplement sizeHint().
table/statistics/statistics.cpp createEditor }
Reimplementado de QTableItem.
bool QCheckTableItem::isChecked | ( | ) | const |
Returns TRUE if the checkbox table item is checked; otherwise returns FALSE.
bool QCheckTableItem::isChecked | ( | ) | const |
void QCheckTableItem::paint | ( | QPainter * | p, |
const QColorGroup & | cg, | ||
const QRect & | cr, | ||
bool | selected | ||
) | [virtual] |
Reimplementado de QTableItem.
virtual void QCheckTableItem::paint | ( | QPainter * | p, |
const QColorGroup & | cg, | ||
const QRect & | cr, | ||
bool | selected | ||
) | [virtual] |
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 );
Reimplementado de QTableItem.
int QCheckTableItem::rtti | ( | ) | const [virtual] |
Returns 2.
Make your derived classes return their own values for rtti()to distinguish between different table item subclasses. You should use values greater than 1000, preferably a large random number, to allow for extensions to this class.
Reimplementado de QTableItem.
int QCheckTableItem::rtti | ( | ) | const [virtual] |
Returns the Run Time Type Identification value for this table item which for QTableItems is 0.
When you create subclasses based on QTableItem 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.
Reimplementado de QTableItem.
virtual void QCheckTableItem::setChecked | ( | bool | b | ) | [virtual] |
void QCheckTableItem::setChecked | ( | bool | b | ) | [virtual] |
If b is TRUE the checkbox is checked; if b is FALSE the checkbox is unchecked.
virtual void QCheckTableItem::setContentFromEditor | ( | QWidget * | w | ) | [virtual] |
Whenever the content of a cell has been edited by the editor w, QTable calls this virtual function to copy the new values into the QTableItem.
If you reimplement createEditor() and return something that is not a QLineEdit you will need to reimplement this function.
table/statistics/statistics.cpp setContentFromEditor }
Reimplementado de QTableItem.
void QCheckTableItem::setContentFromEditor | ( | QWidget * | w | ) | [virtual] |
Reimplementado de QTableItem.
void QCheckTableItem::setText | ( | const QString & | str | ) | [virtual] |
Changes the table item's text to str.
Note that setText() does not update the cell the table item belongs to. Use QTable::updateCell() to repaint the cell's contents.
Reimplementado de QTableItem.
void QCheckTableItem::setText | ( | const QString & | t | ) | [virtual] |
Reimplementado de QTableItem.
QSize QCheckTableItem::sizeHint | ( | ) | const [virtual] |
This virtual function returns the size a cell needs to show its entire content.
If you subclass QTableItem you will often need to reimplement this function.
Reimplementado de QTableItem.
QSize QCheckTableItem::sizeHint | ( | ) | const [virtual] |
Reimplementado de QTableItem.
static int QCheckTableItem::RTTI = 2 [static] |
Reimplementado de QTableItem.