Results 1 to 4 of 4

Thread: Aligning QwtLegend to QwtPlot

  1. #1
    Join Date
    Jun 2012
    Posts
    8
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Aligning QwtLegend to QwtPlot

    Hi all,
    I have set a gradient-background for my QwtPlot and set all Stylesheets of the Widgets, of which QwtPlot consists of, to "background: transparent", to have a consistent gradient.
    But I guess since 6.1 this does not work with QwtLegend anymore - displayed is the color of the QwtPlots parent, not of QwtPlot itself. To work around that, I have set the same gradient to QFrame, which works if the Legend is aligned to the Plot and the heights fit (because Legend is aligned right and gradient has both x-Values on 0) - but in most cases (when there are not enough items displayed inside the Legend) it does not. Therefore I wanted to subclass QwtPlotLayout and just pass the PlotRect, instead of the CanvasRect, when calling the alignLegend function inside the activate function.

    Although I have done a lot of sublassing classes when workking with Qwt, I am stuck here, because a lot of private d_data is initialized in this function and the functions mentionend in the Docs do not provide all the information the d_data-struct has.

    I hope I did not miss something basic :/

    Some directions to sublass QwtPlotLayout, or some other Solution to let the QwtLegend show QwtPlots-background in transparent mode would be really helpful.

    Thanks in advance

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,278
    Thanked 872 Times in 820 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Aligning QwtLegend to QwtPlot

    Quote Originally Posted by bisasatan View Post
    Hi all,I have set a gradient-background for my QwtPlot and set all Stylesheets of the Widgets, of which QwtPlot consists of, to "background: transparent", to have a consistent gradient.
    Be aware of the fact that gradients for the plot canvas might be a performance issue, when you need high refresh rates - especially when running the X11 graphics system. With raster the effect is by far less expensive but still there. Try the itemeditor example with your stylesheet and drag one of the items fast around to see if the effect is relevant for your system.

    Quote Originally Posted by bisasatan View Post
    But I guess since 6.1 this does not work with QwtLegend anymore - displayed is the color of the QwtPlots parent, not of QwtPlot itself.
    I removed all definitions concerning the legend from examples/stylesheets/choco.css and tried it with the legends example: works like expected.

    So there should be something special in your code ...

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    bisasatan (14th May 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    8
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Aligning QwtLegend to QwtPlot

    Uwe,

    thanks for your answer - Performance is not an Issue, I have only implemented a Curvetracker and modified the trackerRect-function to avoid Performance-Problems, when calculating rich-text-size.
    Your testing with legends-example lead me to the Problem - i used 2 stylesheets, one for my MainWindow, one for the Plot, the first one set a background-color for QWidget and Qwt-Legend inherited this, setting QWidget-background transparent before setting the gradient for the Qwt-Plot in the plot-stylesheet solved the problem.

    One more thing I am stuck with: how does one style a checked or unchecked QwtLegendLabel with CSS?

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

    Default Re: Aligning QwtLegend to QwtPlot

    Quote Originally Posted by bisasatan View Post
    ... I have only implemented a Curvetracker and modified the trackerRect-function to avoid Performance-Problems, ...
    As soon as you are using stylesheets Qt enables the Qt::WA_StyledBackground flag, what ends up in always doing full repaints instead of partial updates. For the plot canvas I spent a lot of time hacking against all what happens when using stylesheets, but it doesn't work for all kinds of stylesheets. That is why the hacks can be disabled with QwtPlotCanvas::HackStyledBackground.

    But when you don't have any performance issues don't care about this all.

    Quote Originally Posted by bisasatan View Post
    how does one style a checked or unchecked QwtLegendLabel with CSS?
    The stylesheet concept of Qt is made for Qt widgets only - no way to extend this for 3rdparty widgets. All you have is what is derived from the Qt base widget ( here a QFrame ) and what you can do with properties.

    So your only option is to use a different widget - something styleable - instead of a legend label. This is possible with Qwt <= 6.0, but much easier with Qwt 6.1.

    Uwe

Similar Threads

  1. Aligning 2 plots
    By jerrychan in forum Qwt
    Replies: 2
    Last Post: 25th February 2013, 08:12
  2. QwtLegend orientation on QwtPlot
    By bday1223 in forum Qwt
    Replies: 1
    Last Post: 27th September 2011, 06:26
  3. Aligning widgets in different layouts
    By negritot in forum Qt Tools
    Replies: 4
    Last Post: 9th March 2009, 16:07
  4. Replies: 1
    Last Post: 9th February 2008, 12:46
  5. Aligning a stringlist
    By impeteperry in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2006, 17:45

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.