[Qt-interest] Painting issue with eraseRect
Adam Connell
adam at argoncorp.com
Fri Apr 10 21:36:32 CEST 2009
Greetings,
I am using a tileable PNG image as the background to a QWidget. I then
draw a grid on top of the background. So far so good. Occasionally I
need to label an intersection of the grid. Here I run into a problem.
Simply drawing the text on top of of the grid leaves the text illegible,
so I perform an eraseRect() on the intersection of interest. Instead of
repainting the portion of the PNG that had occupied that area the top
corner of the PNG is painted in its stead. This causes the background in
this area not to match the background in the surrounding area (example
image attached). Is there a way paint the portion of the PNG that was
there originally?
//Redacted code
GobanWidget::GobanWidget(const DisplayData *display_data, QWidget *
parent)
: QWidget(parent)
{
//...
QPalette palette;
palette.setBrush(backgroundRole(),
QBrush(QPixmap(tr(":/resources/board.png"))));
setPalette(palette);
//...
}
//...
void GobanWidget::paintEvent(QPaintEvent *)
{
//...
eraseRect(rect);
painter.drawText(rect,Qt::AlignCenter,
QString::fromStdString(i->text));
}
Regards,
Adam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: paint_problem.png
Type: image/png
Size: 6733 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090410/83f74526/attachment.png
More information about the Qt-interest-old
mailing list