Hi
I am having a bizarre problem with Q_OBJECT macro, if I include the maco in my class declaration the program does not run with the error
"You can't do that without a process to debug"
#include <qwt_plot.h>
class Fitting;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
Q_OBJECT //the program runs if this is if commented out
public:
FittingPlot
(QWidget *parent
= NULL);
public slots:
void upd();
private:
Fitting* tfit;
int mtest;
};
#include <qwt_plot.h>
class QSpinBox;
class QVBoxLayout;
class QDialog;
class Fitting;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class FittingPlot : public QwtPlot
{
Q_OBJECT //the program runs if this is if commented out
public:
FittingPlot(QWidget *parent = NULL);
public slots:
void upd();
private:
QSpinBox* aSpinBox;
QSpinBox* bSpinBox;
QVBoxLayout* layout;
QDialog* diag;
Fitting* tfit;
int mtest;
};
To copy to clipboard, switch view to plain text mode
This the implementation
#include <qwt_plot.h>
#include <QtGui>
#include "FittingPlot.h"
#include "Fitting.h"
FittingPlot
::FittingPlot(QWidget *parent
)
{
layout->addWidget(aSpinBox);
layout->addWidget(bSpinBox);
diag->setLayout(layout);
diag->show();
tfit=new Fitting();
QObject::connect(aSpinBox,
SIGNAL(valueChanged
(int)),tfit,
SLOT(setTargetThreshold
(int)) );
QObject::connect(aSpinBox,
SIGNAL(valueChanged
(int)),tfit,
SLOT(run
()) );
QObject::connect(aSpinBox,
SIGNAL(valueChanged
(int)),
this,
SLOT(upd
()) );
}
void
FittingPlot::upd()
{
mtest++;
}
#include <qwt_plot.h>
#include <QtGui>
#include "FittingPlot.h"
#include "Fitting.h"
FittingPlot::FittingPlot(QWidget *parent)
:QwtPlot(parent),mtest(0)
{
aSpinBox = new QSpinBox;
bSpinBox = new QSpinBox;
layout = new QVBoxLayout();
layout->addWidget(aSpinBox);
layout->addWidget(bSpinBox);
diag=new QDialog(this);
diag->setLayout(layout);
diag->show();
tfit=new Fitting();
QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),tfit, SLOT(setTargetThreshold(int)) );
QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),tfit, SLOT(run()) );
QObject::connect(aSpinBox,SIGNAL(valueChanged(int)),this, SLOT(upd()) );
}
void
FittingPlot::upd()
{
mtest++;
}
To copy to clipboard, switch view to plain text mode
When the code does run (with Q_OBJECT commnented out, the slot upd does not get called with warnin message
"warning: Object::connect: No such slot QwtPlot::upd()
The other two slots work in the Fitting Class work OK
Does anyone have any ideas why this is happening?
Bookmarks