PDA

View Full Version : Unable to have a QLabel sublass with transparent background



yellowmat
4th April 2006, 14:14
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());
}


... but the gray background still appears.

The documentation says about this function :


Draws the label contents using the painter p.
Reimplemented from QFrame.

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 :


void CText::paintEvent(QPaintEvent* event)
{
QPainter* painter = new QPainter(this);
painter->drawText(10, 10, this->text());
}

... 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.

yellowmat
5th April 2006, 16:44
Hi,

Nobody could help me ? :crying: