Results 1 to 5 of 5

Thread: qwtcurve vector

  1. #1
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default qwtcurve vector

    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:
    Qt Code:
    1. QwtPlotCurve myCurve;
    To copy to clipboard, switch view to plain text mode 

    in the constructor then I do:
    Qt Code:
    1. myCurve.attach (myPlot1)
    To copy to clipboard, switch view to plain text mode 

    then something like
    Qt Code:
    1. myCurve.setStyle (QwtPlotCurve:: Dots)
    To copy to clipboard, switch view to plain text mode 

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

    I have done in the attributes:
    Qt Code:
    1. std:: vector <* QwtPlotCurve> mycurve;
    To copy to clipboard, switch view to plain text mode 

    then I do in the constructor:
    Qt Code:
    1. int Nb=8;
    2. int number=2;
    3. for (int k = 0 k <number; + + k)
    4. {
    5. mycurve.push_back (new QwtPlotCurve ());
    6. mycurve [1 + k * Nb] -> attached (myPlot1);
    7. mycurve [1 + k * Nb] -> setStyle (QwtPlotCurve:: Dots)
    8. mycurve [1 + k * Nb] -> setPen (QPen (Qt:: blue, 4));
    9. }
    To copy to clipboard, switch view to plain text mode 

    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 ?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qwtcurve vector

    In first case you use attach(), not attached()

  3. The following user says thank you to stampede for this useful post:

    21did21 (17th June 2011)

  4. #3
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Unhappy Re: qwtcurve vector

    Quote Originally Posted by stampede View Post
    In first case you use attach(), not attached()
    oh! very bad error

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


    Added after 41 minutes:


    i have still a problem:

    i have testing this:

    Qt Code:
    1. for ( int k = 0 ; k < nbDoubleCurve ; ++k )
    2. {
    3. mycurve.push_back(new QwtPlotCurve());
    4. }
    5.  
    6. mycurve[0]->attach( myPlot1 );
    To copy to clipboard, switch view to plain text mode 

    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:


    Qt Code:
    1. for ( int k = 0 ; k < nbDoubleCurve ; ++k )
    2. {
    3. QwtPlotCurve * curve = new QwtPlotCurve();
    4. mycurve.push_back(curve);
    5. }
    6.  
    7. mycurve.at(0)->attach( myPlot1 );
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. for ( int k = 0 ; k < nbDoubleCurve ; ++k )
    2. {
    3. QwtPlotCurve * curve = new QwtPlotCurve();
    4. mycurve.push_back(curve);
    5. }
    6.  
    7. mycurve[0]->attach( myPlot1 );
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by 21did21; 17th June 2011 at 14:45.

  5. #4
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: qwtcurve vector

    it's ok i use now Qvector and it works

  6. #5
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: qwtcurve vector

    i have a other problem with this code :

    i want to plot severals curve

    Qt Code:
    1. for (int i=0;i<1;i++)
    2. {
    3. int timeNb3=0;
    4. timeNb3=Points3_OneXtwoY[i].size();
    5. QVector<double> x3(timeNb3);
    6. QVector<double> y3(timeNb3);
    7. for (int z=0;z<timeNb3;z++)
    8. {
    9. cout << "z " << z << endl;
    10. cout << "i " << i << endl;
    11. cout << "Points3_OneXtwoY " << Points3_OneXtwoY.size() << endl;
    12. cout << "Points3_OneXtwoY[i] " << Points3_OneXtwoY[i].size() << endl;
    13. cout << "Points3_OneXtwoY[i][z] " << Points3_OneXtwoY[i][z].size() << endl;
    14. // x3.append( Points3_OneXtwoY[i][z][0] );
    15. // y3.append( Points3_OneXtwoY[i][z][1] );
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. int timeNb4=Points2_OneXtwoY.size();
    2. QVector<double> x4(timeNb4);
    3. QVector<double> y4(timeNb4);
    4. //i fill Qvectors
    5. for (int z=0;z<timeNb4;z++)
    6. {
    7. x4.append( Points2_OneXtwoY[z][0] );
    8. y4.append( Points2_OneXtwoY[z][1] );
    9. }
    10. myPlot4->replot();
    11. Total.setSamples(x4.data(),y4.data(),x4.size());
    12. repaint();
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. QVector< QwtPlotCurve* > mycurve;
    2. QwtPlotCurve Total;
    To copy to clipboard, switch view to plain text mode 

    can you help me for this problem? thank you
    Last edited by 21did21; 18th June 2011 at 01:20.

Similar Threads

  1. QwtCurve faster repaint
    By baray98 in forum Qwt
    Replies: 2
    Last Post: 21st May 2010, 07:43
  2. vector of vector and computes
    By mickey in forum General Programming
    Replies: 1
    Last Post: 15th May 2008, 13:47
  3. std::vector
    By ToddAtWSU in forum General Programming
    Replies: 1
    Last Post: 28th September 2007, 16:14
  4. insert in a vector of vector
    By mickey in forum General Programming
    Replies: 3
    Last Post: 6th March 2007, 09:45
  5. vector of vector size
    By mickey in forum General Programming
    Replies: 5
    Last Post: 13th February 2007, 16:59

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.