Results 1 to 5 of 5

Thread: Canvas never transparent

  1. #1
    Join Date
    Jul 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Canvas never transparent

    Hi,

    I'm trying to build a plot in a QWidget which has a background. I want to see through my plot the background of this widget.

    I tried a lot of tips given by Uwe on this forum but I have never managed to have my plot fully transparent.

    Here is what I tried :

    With palette :
    setAutoFillBackground( true );
    QColor c( Qt::gray );
    c.setAlpha( 50 );
    QPalette pal;
    pal.setColor( QPalette::Window, c );

    canvas()->setPalette( pal );
    canvas()->setAutoFillBackground( true );
    with stylesheet :
    setAutoFillBackground( true );
    setStyleSheet("QwtPlot{ border: 0px; background: transparent;}");
    canvas()->setStyleSheet("border: 0px; background: transparent;");
    canvas()->setAutoFillBackground(false);
    I must have some issues with the attribute and PaintAttribute but I can't find which one.
    The best result I had was :
    - axis fully transparent but canvas stays white
    - all plot and canvas transparent through the parent widget itself (I can see the widgets under my parent's widget)

    Thanks for your help

  2. #2
    Join Date
    Jul 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Canvas never transparent

    Is it because my question is stupid that nobody answers? Or am I not clear?

    Please I just need this to finish my interface !

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Canvas never transparent

    It's quite simple - when you already know it
    Qt Code:
    1. plot->canvas()->setPaintAttribute( QwtPlotCanvas::PaintPacked, false );
    2. plot->canvas()->setPaintAttribute( QwtPlotCanvas::PaintCached, false );
    3. plot->setCanvasBackground( Qt::transparent );
    To copy to clipboard, switch view to plain text mode 


    Using this method you may get severe performance hit with large plots as caching is disabled, but I'm not sure if there's another way of doing it.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Canvas never transparent

    When the background color is set to transparent you probably don't need to disable the PaintCached mode, what is the important one for the performance when using stuff like rubberbands.

    Uwe

  5. #5
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Canvas never transparent

    I've tested it against qwt5 and you need to disable both in there.
    Not sure about qwt6 though.

Similar Threads

  1. Replies: 8
    Last Post: 17th April 2011, 18:16
  2. Replies: 0
    Last Post: 25th August 2010, 18:39
  3. Replies: 2
    Last Post: 31st May 2010, 12:57
  4. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 17:20
  5. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 03:10

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.