Results 1 to 5 of 5

Thread: multiple plots in QVBoxLayout: different length of legends, but same canvas width?

  1. #1
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default multiple plots in QVBoxLayout: different length of legends, but same canvas width?

    hi everyone,

    i finally got my "multiple-plot-widget" to work, using a QVBoxLayout which contains serveral plots.

    down at the bottom, below all the plots, is a scale which should apply to all plots. therefore, all the plots (i think it's what you call their canvas) have to have the same width - independent from the length of each one's legend text.

    here's a screenshot of what it looks like now:


    as you can see, the painting area's width depends on the legend text's length.

    i tried filling all the legend texts with less characters with spaces, so they're the same length as the longest one, but that doesn't work well, because all the characters have individual widths themselves.

    so my question is, how can i make sure the width of the canvas/painting area is always the same width (in all plots), no matter how long the legend text is?

    thanks in advance and sorry for my poor english!
    sincerely,
    julian
    Last edited by -=Freaky=-; 14th October 2008 at 13:44.

  2. #2
    Join Date
    Oct 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: multiple plots in QVBoxLayout: different length of legends, but same canvas width

    I'm not sure if I'm right, but you should set the geometry the plots to a fixed size using the setGeometry() method.

  3. #3
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: multiple plots in QVBoxLayout: different length of legends, but same canvas width

    thanks, i will try that.

    but if it really sets the geometry of the whole plot widget, it won't work i guess, because the legend on the right (symbol/text) is actually part of the plot widget.
    that's why i probably need to set a fixed size for the "canvas"/"painting area"/"left part"/hope you know what i mean ...

    but i will try setGeometry first before i complain too much.

    // EDIT: as i expected, setGeometry unfortunately doesn't work, because the width/height of all the plots is the same.
    anyway, thanks for the answer, at least one person who read all the stuff!

    // EDIT2: btw: setting the minimum- and maximum-width for the legend item (legend()) and/or canvas (canvas()) doesn't work aswell.
    the legend/canvas is resized, but the "actual painting area" (like when you resize the whole plot widget, the whole painting are + scale is scaled correctly) isn't resized.

    sincerely,
    julian
    Last edited by -=Freaky=-; 15th October 2008 at 12:30.

  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: multiple plots in QVBoxLayout: different length of legends, but same canvas width

    Insert the legend as QwtPlot::ExternalLegend and organize your plots and legends in a QGridLayout.
    Note, that external legends are not printed by QwtPlot::print. So if you need printing you have to call QwtPlot::printLegend() manually.

    Uwe

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

    -=Freaky=- (15th October 2008)

  6. #5
    Join Date
    Aug 2008
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: multiple plots in QVBoxLayout: different length of legends, but same canvas width

    thanks alot uwe!
    i read that part of the docs so many times but just didn't see its importance ...
    everything works fine now!

    sincerely,
    julian

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.