Results 1 to 2 of 2

Thread: Wierd behaviour of transparent QTextEdit

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Wierd behaviour of transparent QTextEdit

    Hi,

    I have a transparent QTextEdit in a widget that has a image background. The only code that I have is to make the backgriound:

    Qt Code:
    1. void climateCover::resizeEvent ( QResizeEvent * /*event*/ )
    2. {
    3. QString file;
    4. file = ":images/svg/climate.svg";
    5.  
    6. QSvgRenderer svgfile(file,0);
    7. QImage img(this->size().width(), this->size().height(), QImage::Format_ARGB32);
    8. img.fill(0);
    9. QPainter painter(&img);
    10. svgfile.render(&painter);
    11.  
    12. QPalette palette;
    13. setAutoFillBackground(TRUE);
    14. palette.setBrush(QPalette::Window,QPixmap::fromImage(img));
    15.  
    16. setPalette(palette);
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    The QTextEdit is on the UI of climateCover.

    However when I run the application the QTextEdit gets its own copy of the background! See image:

    QTextEdit_image1.jpg

    The only thing that QTextEdit has is autofillbackground = true and and alpha of 127. I also have a QPushButton with the same characteristics of alpha and it works fine.

    Any idea what is wrong?

    Thanks,
    Carlos.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Wierd behaviour of transparent QTextEdit

    Did you try setting the background of the text edit to transparent? I think by default it inherits the palette from its parent and thus you end up with the same image as the background.

    By the way, wouldn't it be easier to draw the image in the paint event for the widget instead of setting it to the palette of the widget?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. make transparent a QTextEdit
    By qlands in forum Newbie
    Replies: 3
    Last Post: 6th October 2011, 15:40
  2. Wierd behaviour of QSQLQuery
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2011, 08:51
  3. Wierd behaviour in a slot routine
    By koenig in forum Newbie
    Replies: 7
    Last Post: 29th January 2010, 07:27
  4. Replies: 14
    Last Post: 19th March 2007, 08:48
  5. Strange transparent painting behaviour
    By naresh in forum Newbie
    Replies: 1
    Last Post: 28th September 2006, 07:37

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
  •  
Qt is a trademark of The Qt Company.