更新代码
This commit is contained in:
@@ -126,48 +126,12 @@ void frmUdpClient::append(int type, const QString &data, bool clear)
|
||||
{
|
||||
static int currentCount = 0;
|
||||
static int maxCount = 100;
|
||||
|
||||
if (clear) {
|
||||
ui->txtMain->clear();
|
||||
currentCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentCount >= maxCount) {
|
||||
ui->txtMain->clear();
|
||||
currentCount = 0;
|
||||
}
|
||||
|
||||
if (ui->ckShow->isChecked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//过滤回车换行符
|
||||
QString strData = data;
|
||||
strData = strData.replace("\r", "");
|
||||
strData = strData.replace("\n", "");
|
||||
|
||||
//不同类型不同颜色显示
|
||||
QString strType;
|
||||
if (type == 0) {
|
||||
strType = "发送";
|
||||
ui->txtMain->setTextColor(QColor("#22A3A9"));
|
||||
} else if (type == 1) {
|
||||
strType = "接收";
|
||||
ui->txtMain->setTextColor(QColor("#753775"));
|
||||
} else {
|
||||
strType = "错误";
|
||||
ui->txtMain->setTextColor(QColor("#D64D54"));
|
||||
}
|
||||
|
||||
strData = QString("时间[%1] %2: %3").arg(TIMEMS).arg(strType).arg(strData);
|
||||
ui->txtMain->append(strData);
|
||||
currentCount++;
|
||||
QtHelper::appendMsg(ui->txtMain, type, data, maxCount, currentCount, clear, ui->ckShow->isChecked());
|
||||
}
|
||||
|
||||
void frmUdpClient::error()
|
||||
{
|
||||
append(2, socket->errorString());
|
||||
append(3, socket->errorString());
|
||||
}
|
||||
|
||||
void frmUdpClient::readData()
|
||||
|
||||
Reference in New Issue
Block a user