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
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.