PDA

View Full Version : Dots in complex window mask



HapKoM
9th July 2010, 09:27
Hi all!

I need to create transparent window with non-transparent text on it. Text is changing dynamically, so I create QPixmap object for mask every time i get new text.
When I set window mask, besides text on screen appear strange dots (attached screenshot). I saw this effect on Linux (Qt 4.6.2) and Windows (Qt 4.6.0).
I tried to save mask as png file, and it was correct, without dots.
Have anyone ideas how to fix it? Or is it a Qt bug?

simplified paint event for my widget:


void Widget::paintEvent(QPaintEvent *)
{
QPixmap mask;
mask = QPixmap(800, 600);
QString text[16][32];
QPainter maskPainter(&mask);
maskPainter.setBrush(Qt::black);
maskPainter.setPen(Qt::black);
maskPainter.fillRect(-1,-1, mask.width()+1, mask.height()+1, Qt::white);
maskPainter.setFont(QFont("Liberation Sans", 21, QFont::Bold));
for (int i = 0; i < 16; i++)
{
text[i][0] = "X";
text[i][31] = "X";
}
for (int j = 0; j < 32; j++)
{
text[0][j] = "X";
text[15][j] = "X";
}
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 32; j++)
{
maskPainter.drawText(800*j/32,600*i/16,800/32,600/16, Qt::AlignBottom|Qt::AlignCenter, text[i][j]);
}
}
resize(mask.width(), mask.height());
clearMask();
setMask(mask);
}

Thanks.

totem
9th July 2010, 14:26
Does your window have a QSizeGrip by default, or you added one maybe ? It really looks like a sizeGrip

HapKoM
9th July 2010, 21:58
I solved this problem by using QBitmap instead of QPixmap:) It works correct now.