Hi,
I'm trying to developp a text widget with a transparent background. I subclass the QLabel class and reimplements its drawContents function in which I only draw the text as follow :
void CText
::drawContents(QPainter* painter
) {
painter->drawText(0, 0, this->text());
}
void CText::drawContents(QPainter* painter)
{
painter->drawText(0, 0, this->text());
}
To copy to clipboard, switch view to plain text mode
... but the gray background still appears.
The documentation says about this function :
Draws the label contents using the painter p.
Draws the label contents using the painter p.
Reimplemented from QFrame.
To copy to clipboard, switch view to plain text mode
so I thought maybe the paintEvent handler in a base class does something special as drawing the background, that's why I decided to reimplement the paintEvent handler with the following code :
{
painter->drawText(10, 10, this->text());
}
void CText::paintEvent(QPaintEvent* event)
{
QPainter* painter = new QPainter(this);
painter->drawText(10, 10, this->text());
}
To copy to clipboard, switch view to plain text mode
... it still draws the background
Isn't it possible to just display the text without any background (i.e. with a transparent background) ?
Thanks in advance.
Bookmarks