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 :
#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 :
int currentPointPosition;
double *x;
double *y;
public slots:
void onTimeout();
};
#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>
class Plot : public QwtPlot
{
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 :
#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
->setPen
(QPen(Qt
::green));
curve->attach(this);
curve->setData(x, y, currentPointPosition);
// ...a horizontal line ...
mY
->setLabel
(QString::fromLatin1("t ( ms )"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->attach(this);
// ...a vertical line ...
mX
->setLabel
(QString::fromLatin1("V ( m/s ) ,Ang ( rad/s )"));
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;
}
#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");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axes
setAxisTitle(xBottom, "Temps");
setAxisScale(xBottom, 0.0, 100);
setAxisTitle(yLeft, "");
setAxisScale(yLeft, 0.0, 100);
// add curves
curve = new QwtPlotCurve("Vitesse");
curve->setPen(QPen(Qt::green));
curve->attach(this);
curve->setData(x, y, currentPointPosition);
// ...a horizontal line ...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("t ( ms )"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->attach(this);
// ...a vertical line ...
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("V ( m/s ) ,Ang ( rad/s )"));
mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->attach(this);
timer = new QTimer();
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
#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();
}
#include "plot.h"
int main(int argc, char **argv)
{
QApplication a(argc, 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 :
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.h
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.h
To 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 .
Bookmarks