PDA

View Full Version : I can't connect signal QProcess::started() to a slot



Petruza
27th August 2009, 03:51
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!

yogeshgokul
27th August 2009, 05:48
Please write this Q_OBJECT macro in your class declaration. Like this.



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

public slots:
void process_started();
}

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

spirit
27th August 2009, 06:30
...and rerun qmake & make. :)

Petruza
27th August 2009, 13:48
Thanks Autobot, you're right!
About qmake, I'll let QTcreator handle it ;)
Although QTcreator is pretty slow, don't you think?

yogeshgokul
27th August 2009, 13:52
Thanks Autobot
!! VOILA !!:D


Although QTcreator is pretty slow, don't you think?
If you compare it with VS then yes.:)

Petruza
27th August 2009, 13:54
I hope it's not slow because it's built with QT :(
In your experience, applications made with QT are slow? do they have other downside?

yogeshgokul
27th August 2009, 14:00
I hope it's not slow because it's built with QT :(
Not at all. Its slow on windows because its compiler and debugger(=GDB) is slow. Creator can be used with MSVC on Windows, too – even for debugging. ;)


In your experience, applications made with QT are slow? do they have other downside?
No they are fast enough. Coz C++ is fast.

Petruza
27th August 2009, 14:29
Creator can be used with MSVC on Windows, too – even for debugging. ;)
So I've read, I'll try it.
There's a QT plugin for MSVC right?

yogeshgokul
27th August 2009, 14:51
Yes.. :) !