Results 1 to 2 of 2

Thread: Unable to have a QLabel sublass with transparent background

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Unable to have a QLabel sublass with transparent background

    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 :
    Qt Code:
    1. void CText::drawContents(QPainter* painter)
    2. {
    3. painter->drawText(0, 0, this->text());
    4. }
    To copy to clipboard, switch view to plain text mode 

    ... but the gray background still appears.

    The documentation says about this function :
    Qt Code:
    1. Draws the label contents using the painter p.
    2. 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 :
    Qt Code:
    1. void CText::paintEvent(QPaintEvent* event)
    2. {
    3. QPainter* painter = new QPainter(this);
    4. painter->drawText(10, 10, this->text());
    5. }
    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.

  2. #2
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Unable to have a QLabel sublass with transparent background

    Hi,

    Nobody could help me ?

Similar Threads

  1. QLCDNumber with transparent background?
    By PolyVox in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2008, 06:34
  2. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 06:34
  3. Replies: 3
    Last Post: 8th December 2006, 19:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.