QT 小问题
void MainWindow::on_startButon_clicked(bool checked)
{
if(ui->comOneCB->checkState()) //1
{
testCOM(tr("COM2"), tr("串口1"));
qApp->processEvents();
}
if(ui->comTwoCB->checkState()) //2
{
testCOM(tr("COM4"), tr("串口2"));
qApp->processEvents();
}
if(ui->masterUSBCB->checkState()) //3
{
masterUSB();
qApp->processEvents();
}
if(ui->netCB->checkState()) //4
{
netConnect();
qApp->processEvents();
}
}
void MainWindow::testCOM(QString com, QString device)
{
if(recvbuff == sendbuff)
{
ui->textEdit->append(tr(" 正常"));
}
else
{
ui->recordtextEdit->append(tr("错误"));
}
}
.
.
.
.
如何在 ui->recordtextEdit->append(tr("错误")); 时停止//2 //3 //4的测试。 路过高手帮忙写下代码,菜鸟谢过
[解决办法]
你的testCOM函数定义个返回值,判断真假的,头文件里不要void 这么写了,bool testCOM(...,...)
然后
bool MainWindow::testCOM(QString com, QString device) { if(recvbuff == sendbuff) { ui->textEdit->append(tr(" 正常")); return true; } else { ui->recordtextEdit->append(tr("错误")); return false; }}