编译QT代码时出现奇怪和未知错误

时间:2017-02-14 14:00:02

标签: qt

enter image description here我不知道为什么我会收到错误或这些陈述。当我为x86_64系统编译它时,相同的代码工作正常,但是当我将目标更改为Beaglebone Black并切换到angstrom工具链时,QTcreator开始在这些行中给出错误。

//connect(process, &QProcess::readyReadStandardError, [=]{
ui->textBrowser->append(process->readAllStandardError());
});
connect(process, &QProcess::readyReadStandardOutput, [=]{
ui->textBrowser->append(process->readAllStandardOutput());
});

错误用于表达式“[=]”。事实上我不知道为什么会出现这个错误。这可能与版本有关,bcoz BBB有qt4嵌入式。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:1)

将信号连接到c ++ 11 lambda的语法已添加到Qt 5.由于以前的版本(Qt4)没有为connect()定义正确的签名,因此您无法使用它。您应该转换代码以匹配正确的语法:

connect(process, SIGNAL(readyReadStandardError()), receiver, SLOT(yourCustomSlot()) );

声明如下:

class MyReceiverClass {

slots:
    void yourCustomSlot() {
        ui->textBrowser->append(process->readAllStandardOutput());
    }
};
相关问题