@@ -75,6 +75,9 @@ namespace HFA {
7575 }
7676
7777 MainWindow::MainWindow (QWidget *parent) : QMainWindow(parent) {
78+ // 初始化错误文本格式为红色
79+ m_errorFormat.setForeground (Qt::red);
80+
7881 auto rmProvider = ExecutionProvider::CPU;
7982 int device_id = -1 ;
8083 if (isDmlAvailable (device_id)) {
@@ -394,7 +397,7 @@ namespace HFA {
394397 m_failIndex.append (filename + " : " + msg);
395398 progressBar->setValue (m_workFinished);
396399
397- out-> appendPlainText (filename + " : " + msg);
400+ appendErrorMessage (filename + " : " + msg);
398401
399402 if (m_workFinished == m_workTotal) {
400403 slot_threadFinished ();
@@ -405,9 +408,6 @@ namespace HFA {
405408 m_workFinished++;
406409 progressBar->setValue (m_workFinished);
407410
408- if (!msg.isEmpty ())
409- out->appendPlainText (filename + " : " + msg);
410-
411411 if (m_workFinished == m_workTotal) {
412412 slot_threadFinished ();
413413 }
@@ -418,17 +418,18 @@ namespace HFA {
418418 .arg (m_workTotal - m_workError)
419419 .arg (m_workError)
420420 .arg (m_workTotal);
421- if (m_workError > 0 ) {
422- QString failSummary = " Failed tasks:\n " ;
423- for (const QString &fileMsg : m_failIndex) {
424- failSummary += " " + fileMsg + " \n " ;
425- }
426- out->appendPlainText (failSummary);
427- m_failIndex.clear ();
428- }
421+
429422 QMessageBox::information (this , QApplication::applicationName (), msg);
423+
430424 m_workFinished = 0 ;
431425 m_workError = 0 ;
432426 m_workTotal = 0 ;
433427 }
428+
429+ void MainWindow::appendErrorMessage (const QString &message) const {
430+ QTextCursor cursor = out->textCursor ();
431+ cursor.movePosition (QTextCursor::End);
432+ cursor.insertText (message + " \n " , m_errorFormat);
433+ out->ensureCursorVisible ();
434+ }
434435}
0 commit comments