如何在同一个QThread中调用属于QThread的插槽?

时间:2015-04-20 14:36:54

标签: linux qt signals-slots qthread qprocess

我有一个启动外部Linux二进制文件的QThread。每当我从外部Linux二进制文件获得输出时,我都使用connect()来调用slot(),这是QThread的一部分。这对我来说似乎不起作用。谁能告诉我下面的代码有什么问题?

class ThreadPowerSubSystem : public QThread
{

public:
ThreadPowerSubSystem(){ }

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

private:


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

此外,我需要调用一个函数来显示该槽内的对话框。谁能告诉我一个如何做的例子?

0 个答案:

没有答案