View Full Version : Plots and Layouts
Ozzy
29th November 2007, 08:00
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
Uwe
29th November 2007, 08:33
There is nothing special with QwtPlot, when using it in QLayouts.
What did you try ?
Uwe
Ozzy
29th November 2007, 08:45
Hi Uwe,
thanks for your answer. I've tried something like this:
QwtPlot *myPlot = new QwtPlot;
QGridLayout *layout = new QGridLayout( this );
setTitle( "Titel" );
QwtPlotCurve *plot = new QwtPlotCurve( "Plot1 " );
plot->setPen(QPen(Qt::black));
plot->attach(this);
plot->setStyle(QwtPlotCurve::Sticks);
double vx[vec.size()];
double vy[vec.size()];
for(uint i=0; i<vec.size(); i++) {
vx[i]= i;
vy[i]= vec[i];
}
plot->setData(vx, vy, vec.size());
plot->attach(myPlot);
layout->addWidget( myPlot );
replot();
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
Ozzy
29th November 2007, 08:55
Hi,
i guess I know whats wrong
class Plot : public QwtPlot
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
rambo83
17th November 2009, 08:42
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:
ui_frame_for_plot = qFindChild<QFrame*>(this, "frame_for_plot");
Plot *d_plot;
d_plot = new Plot(ui_frame_for_plot);
d_plot->showSpectrogram(true);
How can I integrate a QwtPlot into another widget?
Thank you.
best regards,
Vitali
rambo83
17th November 2009, 09:00
Ok, I have solved it myself by inserting the QwtPlot into a layout:
QVBoxLayout * layout_plot = new QVBoxLayout(ui_frame_for_plot);
// build object of class "Plot", which will plot the 2D surfaces
d_plot = new Plot();
layout_plot->addWidget(d_plot);
d_plot->showSpectrogram(true);
Now the plot is displayed.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.