Results 1 to 5 of 5

Thread: qwt setCanvasBackground() won't

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default qwt setCanvasBackground() won't

    I am using qwt to do some graphing.

    I have a qwt plot on a stacked widget page. Everything in the graph
    displays properly but for some reason I cannot set the background color.

    I've successfully done it from in a test app that doesn't use the stackedwidget.

    I also noticed that if I have > 1 qwtplot, ie another plot on a different page and
    I set both of them, then one of them would get the background changed
    but not both.

    I'm doing:

    Output_Graph->setCanvasBackground(QColor(Qt::darkBlue));

    Any ideas? I'm going bonkers...

    Mark

  2. #2
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qwt setCanvasBackground() won't

    Qwt 6.1.2, Windows 7, Qt 5.3.1 - the same issue.

    setCanvasBackground() seems to do nothing at all.

  3. #3
    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: qwt setCanvasBackground() won't

    setCanvasBackground() had once been introduced for the designer, where you need to have a property.
    But when looking at the implementation you will probably see, what goes wrong - maybe setting another canvas later.

    Qt Code:
    1. void QwtPlot::setCanvasBackground( const QBrush &brush )
    2. {
    3. QPalette pal = canvas()->palette();
    4. pal.setBrush( QPalette::Window, brush );
    5.  
    6. canvas()->setPalette( pal );
    7. }
    To copy to clipboard, switch view to plain text mode 
    Uwe

  4. #4
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qwt setCanvasBackground() won't

    Unfortunately this seems to have no effect on my PC...

    After many experiments the only way to set plot and canvas backgrounds properly, was the following:

    QString styleSheet("background: gray; color: yellow;");
    plot->setStyleSheet(styleSheet);
    plot->canvas()->setStyleSheet(styleSheet);

    The application has its own custom style sheet which is set globally, so probably that could be the reason why just changing plotter's palette has no effect.

  5. #5
    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: qwt setCanvasBackground() won't

    Quote Originally Posted by Sintegrial View Post
    The application has its own custom style sheet which is set globally, so probably that could be the reason why just changing plotter's palette has no effect.
    Sure, styleSheets disable the palette in general. When using style sheets you can expect to have more of these conflicts - it was a questionable concept from the very beginning and maximal annoying for 3rd party libs.
    But anyway under examples/stylesheets you find a couple of examples for how to manipulate QwtPlot widgets using style sheets.

    Uwe

Similar Threads

  1. QWT fails in debug build
    By steg90 in forum Qwt
    Replies: 1
    Last Post: 11th November 2011, 07:53
  2. Qwt 5.0.2
    By Uwe in forum Qt-based Software
    Replies: 1
    Last Post: 20th September 2007, 19:21
  3. How to upgrade Qwt 5.0.1 to Qwt 5.0.2
    By luffy27 in forum Qwt
    Replies: 1
    Last Post: 15th July 2007, 20:55
  4. Qwt 5.0.1
    By Uwe in forum Qt-based Software
    Replies: 0
    Last Post: 26th February 2007, 22:24
  5. use interesting QWT Library with QT3.X
    By raphaelf in forum Qwt
    Replies: 2
    Last Post: 23rd January 2006, 12:24

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.