Dear all,
(My question is around QPainter. Please move it to right section if its not the relevant place)
My application is real time, which reads value and updates the same region.
Here is my code does that
//Set pen to black.
m_pPainter->setPen(textColor);
// Set the font to the QPainter
m_pPainter->setFont(textFont);
// Fill the background color of the text
m_pPainter->fillRect(
relPosX,
relPosY,
textWidth,
textHeight,
textBgColor
);
//Draw text at the specified co-ordinates
m_pPainter->drawText(
relPosX,
relPosY,
textWidth,
textHeight,
Qt::AlignLeft | Qt::AlignVCenter,
displayText
);
Since this will be executed continuously, it was over writing the text with over lap.
To avoid that,
I have added the below line which solved the problem
m_pPainter->eraseRect(relPosX, relPosY, textWidth, textHeight);
But, I have another problem because of this.
What happens is that, eraseRect(…) clears the complete rectangular region, and it erases the color of the background.
What is the best way to clear the text (“just clearing the text”), without loosing the background?
Can i get your help please to solve this problem?
Please let me know if my explanation is not clear.
Thank you,
Kumar
↧