lundi 20 avril 2015

How to call a slot,that belongs to a QThread, within that same QThread?

I have a QThread that starts an external linux binary. I use connect() to call a slot(), which is part of the QThread, whenever I get an output from that external linux binary. This seems not to work for me. Can anyone tell me what is wrong in the below code?

class ThreadPowerSubSystem : public QThread
{

public:
ThreadPowerSubSystem(){ }

private slots:
void checkForTwoSecPress()
{
    qWarning("button pressed");
}

private:


void run()
{
    QProcess *powerProcess = new QProcess();
    powerProcess->execute("/home/testApp/button");
    connect(powerProcess, SIGNAL(readyRead()), this, SLOT(checkForTwoSecPress()));
    exec();
}
};

Also I need to call a function to display a dialog inside that slot. Can anyone show me an example on how to do it? Thanks.

Aucun commentaire:

Enregistrer un commentaire