PDA

View Full Version : qwtcurve vector



21did21
17th June 2011, 01:12
Hello all,

I have a new little trouble with QWT
usually when I want to make a curve i do this:

I put an attribute like this:

QwtPlotCurve myCurve;

in the constructor then I do:

myCurve.attach (myPlot1)

then something like

myCurve.setStyle (QwtPlotCurve:: Dots)

now I wish have a vector of curve and do the same thing

I have done in the attributes:

std:: vector <* QwtPlotCurve> mycurve;

then I do in the constructor:


int Nb=8;
int number=2;
for (int k = 0 k <number; + + k)
{
mycurve.push_back (new QwtPlotCurve ());
mycurve [1 + k * Nb] -> attached (myPlot1);
mycurve [1 + k * Nb] -> setStyle (QwtPlotCurve:: Dots)
mycurve [1 + k * Nb] -> setPen (QPen (Qt:: blue, 4));
}

the problem is that I get an error:

mycurve Have No member "attached"

it's weird because in the first case it works with a curve too here it's just a vector of curve ?

stampede
17th June 2011, 01:23
In first case you use attach(), not attached()

21did21
17th June 2011, 09:47
In first case you use attach(), not attached()

oh! very bad error :o :o

=> thank you for this remark, i don't know why i have but this "ed" :p
thank a lot ;)

Added after 41 minutes:

i have still a problem:

i have testing this:


for ( int k = 0 ; k < nbDoubleCurve ; ++k )
{
mycurve.push_back(new QwtPlotCurve());
}

mycurve[0]->attach( myPlot1 );

but my code bug if i put this line "mycurve[0]->attach( myPlot1 );"

=> all windows are closed and i have a message from my OS that is want to close this application

EDIT:
i have tested too:


for ( int k = 0 ; k < nbDoubleCurve ; ++k )
{
QwtPlotCurve * curve = new QwtPlotCurve();
mycurve.push_back(curve);
}

mycurve.at(0)->attach( myPlot1 );

or


for ( int k = 0 ; k < nbDoubleCurve ; ++k )
{
QwtPlotCurve * curve = new QwtPlotCurve();
mycurve.push_back(curve);
}

mycurve[0]->attach( myPlot1 );

but i have the same error (application blocked and execution finish with the code -1073741819)

i don't know how i can make this curve vector

21did21
17th June 2011, 16:15
it's ok i use now Qvector and it works

21did21
18th June 2011, 00:07
i have a other problem with this code :

i want to plot severals curve


for (int i=0;i<1;i++)
{
int timeNb3=0;
timeNb3=Points3_OneXtwoY[i].size();
QVector<double> x3(timeNb3);
QVector<double> y3(timeNb3);
for (int z=0;z<timeNb3;z++)
{
cout << "z " << z << endl;
cout << "i " << i << endl;
cout << "Points3_OneXtwoY " << Points3_OneXtwoY.size() << endl;
cout << "Points3_OneXtwoY[i] " << Points3_OneXtwoY[i].size() << endl;
cout << "Points3_OneXtwoY[i][z] " << Points3_OneXtwoY[i][z].size() << endl;
// x3.append( Points3_OneXtwoY[i][z][0] );
// y3.append( Points3_OneXtwoY[i][z][1] );
}
}

i try this code and it provide this results:

http://imageshack.us/photo/my-images/39/consoleaf.jpg/

so if i decomment the line in the previous code, it should not be error ?

=> when i run this code i have this error:
http://imageshack.us/photo/my-images/217/errorpvk.jpg/


it's strange what this code don't work because this code works nice:


int timeNb4=Points2_OneXtwoY.size();
QVector<double> x4(timeNb4);
QVector<double> y4(timeNb4);
//i fill Qvectors
for (int z=0;z<timeNb4;z++)
{
x4.append( Points2_OneXtwoY[z][0] );
y4.append( Points2_OneXtwoY[z][1] );
}
myPlot4->replot();
Total.setSamples(x4.data(),y4.data(),x4.size());
repaint();

i have only one difference betwen this codes: the declaration of curve in the header:


QVector< QwtPlotCurve* > mycurve;
QwtPlotCurve Total;

can you help me for this problem? thank you