thanks for your help ,
i'll try but logically data in constructor should be given only one time .
thanks for your help ,
i'll try but logically data in constructor should be given only one time .
I think you don't understand me. You can keep the data in two places - one of them is initialized and filled with data in the constructor. The other is the plot itself that is fed with the data from the first container using a timer.
Here is a skeleton of a code doing what I mean:
Qt Code:
X::X(){ for(int i=0;i<100;i++){ x[i]=i; y1[i]=i*i; y2[i]=i; } currentPointPosition = 1; // currentPointPosition is a member variable updateData(); connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); timer->start(500); //... } void X::onTimeout(){ currentPointPosition++; if(currentPointPosition>100) currentPointPosition = 1; updateData(); } void X::updateData(){ curve1->setData(x, y1, currentPointPosition); }To copy to clipboard, switch view to plain text mode
oswalidos (10th March 2009)
hello ,
thanks for the skeleton,i'm trying to apply your idea but i get blocked is something .
when i define the macro Q_OBJECT an error appear :
Qt Code:
undefined refrence to vtabe for plotTo copy to clipboard, switch view to plain text mode
my .pro is :
Qt Code:
TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += C:\svn\qwt\qwt\src LIBS += C:\svn\qwt\qwt\lib\qwtd5.dll CONFIG += debug # Input SOURCES += main.cppTo copy to clipboard, switch view to plain text mode
main.cpp :
Qt Code:
{ //Q_OBJECT public: Plot(); void pointByPoint(); private : QwtPlotCurve *curve1; int currentPointPosition; QTimer *timer; double *x; double *y; /* public slots: void onTimeout(); */ }; Plot::Plot() { x=new double[100]; y=new double[100]; for(int i=0;i<100;i++){ x[i]=i; y[i]=i*i; } //...... //connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } /* void Plot::onTimeout(){ //each timeout data will currentPointPosition++; // be added to the curve if(currentPointPosition>100) currentPointPosition = 1; curve1->setData(x, y1, currentPointPosition); } */ void Plot::pointByPoint(){ //calling this method provoque painting curve "slowly" while(true){ timer->start(500); } } int main(int argc, char **argv) { Plot *myPlot = new Plot(); myPlot->autoRefresh(); myPlot->resize(600,400); myPlot->show(); //myPlot->pointByPoint(); return a.exec(); }To copy to clipboard, switch view to plain text mode
thanks for your help![]()
oswalidos (10th March 2009)
ohhh ,sorry ,i'm working with Qt creator and i forgot about qmake !!
thanks a lot
it works first time but now :
this code still make error : undefined reference to "vtable for plot"
Qt Code:
{ Q_OBJECT public: Plot(); void pointByPoint(); private : QwtPlotCurve *curve; int currentPointPosition; QTimer *timer; double *x; double *y; public slots: void onTimeout(); }; Plot::Plot() { x=new double[100]; y=new double[100]; for(int i=0;i<100;i++){ x[i]=i; y[i]=i*i; } //........ connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } void Plot::onTimeout(){ //each timeout data will currentPointPosition++; // be added to the curve if(currentPointPosition>100) currentPointPosition = 1; curve->setData(x, y, currentPointPosition); } void Plot::pointByPoint(){ //calling this method provoque painting curve "slowly" for(int i=0;i<200;i++){ timer->start(500); } } int main(int argc, char **argv) { Plot *myPlot = new Plot(); myPlot->autoRefresh(); myPlot->resize(600,400); myPlot->show(); myPlot->pointByPoint(); return a.exec(); }To copy to clipboard, switch view to plain text mode
it's a shame to ask many questions but there is no documentation about qwt and i'm still beginner .
thanks for your help![]()
Last edited by oswalidos; 10th March 2009 at 21:52.
Your issues are not related to Qwt. I'm even thinking about moving the thread to the newbie section of the board.
The Q_OBJECT macro has to be placed in a header file (with .h extension). It's possible to place it in an implementation file but it requires some additional work so let's try avoiding it for now. So if your class declaration is in an implementation (.cpp) file, move it to a header file, add the file to your project and rerun qmake and make.
oswalidos (10th March 2009)
ok, i did but macro problem persist like this :
D:/P2M/courbe/debug/courbe.exe exited with code 0
Starting D:/P2M/courbe/debug/courbe.exe...
D:/P2M/courbe/debug/courbe.exe exited with code -1073741819
if i make macro and slots as a comment everything seems work !
thx again![]()
If your application crashes, it's not because of lack or presence of Q_OBJECT macro. Use a debugger to see where it crashes and why.
oswalidos (10th March 2009)
i don't know how to debug in console mode but i tried with qt creator .
when i run debug mode ,it still running with no information given ,debugger don't run until the first break point , it's written dbg running .
plot.h :
Qt Code:
#include <QtGui> #include <qwt_plot.h> #include <qwt_plot_curve.h> #include <qwt_plot_marker.h> #include <qwt_plot_curve.h> #include <qwt_legend.h> #include <qwt_series_data.h> #include <qwt_text.h> #include <math.h> { Q_OBJECT public: Plot(); ~Plot(); void pointByPoint(); private : QwtPlotCurve *curve; int currentPointPosition; QTimer *timer; double *x; double *y; public slots: void onTimeout(); };To copy to clipboard, switch view to plain text mode
plot.cpp :
Qt Code:
#include "plot.h" Plot::Plot() { x=new double[100]; y=new double[100]; for(int i=0;i<100;i++){ x[i]=i; y[i]=i*i; } currentPointPosition=1; setTitle("Vitesse et angle de braquage en fonction du temps"); // Set axes setAxisTitle(xBottom, "Temps"); setAxisScale(xBottom, 0.0, 100); setAxisTitle(yLeft, ""); setAxisScale(yLeft, 0.0, 100); // add curves curve->attach(this); curve->setData(x, y, currentPointPosition); // ...a horizontal line ... mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mY->attach(this); // ...a vertical line ... mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop); mX->attach(this); connect(timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } void Plot::onTimeout(){ //each timeout data will currentPointPosition++; // be added to the curve if(currentPointPosition>100) currentPointPosition = 1; curve->setData(x, y, currentPointPosition); } void Plot::pointByPoint(){ //calling this method provoque painting curve "slowly" for(int i=0;i<200;i++){ timer->start(500); } } Plot::~Plot(){ delete x; delete y; }To copy to clipboard, switch view to plain text mode
main.cpp
Qt Code:
#include "plot.h" int main(int argc, char **argv) { Plot *myPlot = new Plot(); myPlot->autoRefresh(); myPlot->resize(600,400); myPlot->show(); myPlot->pointByPoint(); return a.exec(); }To copy to clipboard, switch view to plain text mode
.pro :
Qt Code:
TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += C:\svn\qwt\qwt\src LIBS += C:\svn\qwt\qwt\lib\qwtd5.dll CONFIG += debug # Input SOURCES += main.cpp \ plot.cpp HEADERS += plot.hTo copy to clipboard, switch view to plain text mode
i made as comment Q_OBJECT and my slot and it works ,i checked debugger too,it's ok with it under Qtcreator .
No , I'm sorry ,
i show the code cuz i suppose there is a simple mistake i can't see it as a Qt beginner .
Last edited by oswalidos; 11th March 2009 at 19:20.
hello ,
i realized that my problem have no relation with my code.
in fact a simple application like "simple_plot" works normally when i create a new project ,move sources and modify *.pro ,but when i do the same for other example like "real_time plot" and try to build it , i have the same problem with a warning(exited with code -1073741819 ,no errors ,warning: #warning better use QwtData) and degugger don't works anymore .
so it's a configuration problem .
i downloaded qwt 5.2 from svn but it's the same problem !
-each time i want to run my application from Qt console or from Qt creator i have to add qwtd5.dll to debug folder,everybody do that ?
-i want to buid Qt in debug mode ,it takes time ,finally it generate errors related with visual studio 2008
-why to build Qt in debug mode?
-mingw's gdb isn't enough to debug Qt applications since we're using Qt's sources ?
-what about .pri and .prf ? should i modify one ?
-why debugger under Qt creator works(just for an application without macro Q_OBJECT) even if Qt isn't buit in debug mode ?
please look up my .pro
if my questions proves that i'm lost ,some links will be enough to stop annoying you .
regards
Last edited by oswalidos; 11th March 2009 at 19:55.
Bookmarks