Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void Q3TableItem::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

Reimplemented in Q3ComboTableItem, and Q3CheckTableItem.

Definition at line 733 of file q3table.cpp.

References alignment(), QPainter::drawPixmap(), QPainter::drawText(), QPainter::fillRect(), QPixmap::height(), QRect::height(), QPixmap::isNull(), QPainter::setPen(), text(), QRect::width(), and QPixmap::width().

Referenced by Q3Table::paintCell().

    p->fillRect(0, 0, cr.width(), cr.height(),
                 selected ? cg.brush(QColorGroup::Highlight)
                          : cg.brush(QColorGroup::Base));

    int w = cr.width();
    int h = cr.height();

    int x = 0;
    if (!pix.isNull()) {
        p->drawPixmap(0, (cr.height() - pix.height()) / 2, pix);
        x = pix.width() + 2;

    if (selected)
    p->drawText(x + 2, 0, w - x - 4, h,
                 wordwrap ? (alignment() | WordBreak) : alignment(), text());

Generated by  Doxygen 1.6.0   Back to index