Results 1 to 6 of 6

Thread: Plots and Layouts

  1. #1
    Join Date
    Nov 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Plots and Layouts

    Hi,

    I'm trying to put 3 plots in a Dialog, one big on the left, and two other one above tho other on the right side.
    But I don't know how, cause I can't find a way to use Layout with Plot.

    Can you help me with this?

    best regards, Ozzy

  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: Plots and Layouts

    There is nothing special with QwtPlot, when using it in QLayouts.
    What did you try ?

    Uwe

  3. #3
    Join Date
    Nov 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Plots and Layouts

    Hi Uwe,

    thanks for your answer. I've tried something like this:

    Qt Code:
    1. QwtPlot *myPlot = new QwtPlot;
    2. QGridLayout *layout = new QGridLayout( this );
    3.  
    4. setTitle( "Titel" );
    5. QwtPlotCurve *plot = new QwtPlotCurve( "Plot1 " );
    6.  
    7. plot->setPen(QPen(Qt::black));
    8. plot->attach(this);
    9. plot->setStyle(QwtPlotCurve::Sticks);
    10.  
    11. double vx[vec.size()];
    12. double vy[vec.size()];
    13. for(uint i=0; i<vec.size(); i++) {
    14. vx[i]= i;
    15. vy[i]= vec[i];
    16. }
    17.  
    18. plot->setData(vx, vy, vec.size());
    19.  
    20. plot->attach(myPlot);
    21. layout->addWidget( myPlot );
    22.  
    23. replot();
    To copy to clipboard, switch view to plain text mode 

    But now there are two plot, and one is on top of the other, but a little bit shifted.
    Can you help me with this?

    Greetings from germany, Ozzy

  4. #4
    Join Date
    Nov 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X

    Default

    Hi,

    i guess I know whats wrong
    Qt Code:
    1. class Plot : public QwtPlot
    To copy to clipboard, switch view to plain text mode 
    Thats, why he paint the second graph. But what can I do? If I use something like QFrame, then repaint() is unknown...

    MfG, Ozzy

    Ok, it works. But I'm interest, if theres a better way to go...

    Ozzy
    Last edited by wysota; 29th November 2007 at 13:26. Reason: Posts merged

  5. #5
    Join Date
    Nov 2009
    Posts
    94
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plots and Layouts

    Hello,

    can you tell me, how did you manage to draw the plots within a QFrame?

    I wanted to include the spectrogram example of qwt in my programm, but nothing is displayed there:

    Qt Code:
    1. ui_frame_for_plot = qFindChild<QFrame*>(this, "frame_for_plot");
    2.  
    3. Plot *d_plot;
    4.  
    5. d_plot = new Plot(ui_frame_for_plot);
    6. d_plot->showSpectrogram(true);
    To copy to clipboard, switch view to plain text mode 

    How can I integrate a QwtPlot into another widget?

    Thank you.

    best regards,

    Vitali

  6. #6
    Join Date
    Nov 2009
    Posts
    94
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plots and Layouts

    Ok, I have solved it myself by inserting the QwtPlot into a layout:

    Qt Code:
    1. QVBoxLayout * layout_plot = new QVBoxLayout(ui_frame_for_plot);
    2.  
    3. // build object of class "Plot", which will plot the 2D surfaces
    4. d_plot = new Plot();
    5. layout_plot->addWidget(d_plot);
    6. d_plot->showSpectrogram(true);
    To copy to clipboard, switch view to plain text mode 

    Now the plot is displayed.

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.