views:

518

answers:

1

Edit: Solved.

Hi, I'm starting with QT, I try to connect a slot to signal QProcess::started() but can't. QObject::connect() returns false. Any idea what am I doing wrong?

Here's part of the code:


class foo : public QObject
{   
 public:
  QProcess *process;

 public slots:
  void process_started();
}

foo::foo()
{
 process = new QProcess();
 bool status = QObject::connect( process, SIGNAL( started() ), this, SLOT( process_started() ) );
 // status is false, meaning the slot and signal couldn't be connected
}

I know the process starts successfully because I tried process->WaitForStarted() and it returns true. But I put a breakpoint at the slot foo::process_started() and it never gets hit. What's the problem here? Thanks!

+3  A: 

You forgot to put Q_OBJECT in your class declaration. Without that keyword, moc doesn't know it needs to generate metaobject information for your class.

Intransigent Parsnip
That's it, thanks!
Petruza