Problems with Q_OBJECT macro
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"
Code:
#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;
};
This the implementation
Code:
#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++;
}
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?
Re: Problems with Q_OBJECT macro
try to remove #include <qwt_plot.h> from cpp, but I think this not a problem.
Re: Problems with Q_OBJECT macro
Thanks for the advice, but I still does not work, I still get the error
"You can't do that without a process to debug"
I am using eclipse on winXp.
I also get the same problem with QDevelop but different error
Program received signal SIGSEGV, Segmentation fault.
Program exited with code 030000000005.
Anyone any ideas?
Thanks
Re: Problems with Q_OBJECT macro
could the crash be because u have three different slots connected to the same signal and the order in which they r executed might not be appropriate and is causing the crash?
Re: Problems with Q_OBJECT macro
Thanks but no that isn't the problem, the slot functions are presently dummy functions and the call order doesn't matter.
I have rejigged the code, rather than inherit from QwtPlot, I inherit from QWidget, it runs Ok (i.e displays the Widget). The problem is that I want to inherit from QwtPlot
Thanks
Re: Problems with Q_OBJECT macro
maybe you should better as this question in Qwt subforum and Uwe probably helps you :)
Re: Problems with Q_OBJECT macro
Re: Problems with Q_OBJECT macro
Did you remember to rerun qmake after adding the macro? For me it looks like the program fails to rebuild with the macro thus the message you get. Qwt has nothing to do with it.
Re: Problems with Q_OBJECT macro
i agree with wysota. please make a clean metaobject file which qmake already does,
start with a new pro file, a new environment .
moc -o x_moc x.h
add the moc file in the main cpp file
#include "x_moc"
kindly read Q_OBJECT problems due to moc..
it may not exactly solve the problem but good to give a try.
Re: Problems with Q_OBJECT macro
Are you sure it is correct the eclipse configuration? becuase maybe there is a Eclipse problem to find the debugger. Specify the gdb ruth in debug configuration.
And have you include the QT and the compiler (MinGw) in the CLASS PATH?
Cheers
Re: Problems with Q_OBJECT macro
Hi
I dont think it is an eclipe/qt problem as I have other qt/qwt projects that work just fine
If my class inherits from QWidget, I dont have a problem, only when inheriting from QwtPlot
Thanks
Re: Problems with Q_OBJECT macro
Please provide a minimal compilable example reproducing the problem.
1 Attachment(s)
Re: Problems with Q_OBJECT macro
I have attached the project as a zip file, hope that OK
Re: Problems with Q_OBJECT macro
try this
Code:
{
Q_OBJECT
public:
....
};
FittingPlot
::FittingPlot(QWidget *parent
) {
}
Re: Problems with Q_OBJECT macro
Thanks but I still get the same error
"You can't do that without a process to debug."
Grrr
Re: Problems with Q_OBJECT macro
did you rebuild all project? did you remove old obj-files? did you run qmake after cleaning project dir?
Re: Problems with Q_OBJECT macro
Yes, after cleaning the project I checked the files were deleted Ok. I think Eclipse handles the Qmake process, however I did it manually from the command line. But I still get the same error.
Thanks
Re: Problems with Q_OBJECT macro
Quote:
Originally Posted by
dbrmik
I have attached the project as a zip file, hope that OK
It works for me without a problem. A simple qmake && make compiled the project just fine. I have Qwt 5.1.1 installed with Qt 4.4.3.
Re: Problems with Q_OBJECT macro
Thanks wysota, that's good to know. Still not working here, I also have Qwt 5.1.1 installed with Qt 4.4.3 running on xp using eclipse. I get the same problem usng QDevelop. As I metioned earlier I have other projects using the qwt library, however I am not subclassing QwtPlot, I'm adding it as a widget to a MainWindow with no problems, I suppose I'll have to live with it for now
Thanks once again for your time
Re: Problems with Q_OBJECT macro
What happens if in FittinPlot.cpp you substitute '#include "FittingPlot.h' for '#include "FittinPlot.moc"'?