阶段备份
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QTextEdit>
|
||||
#include <QDateTime>
|
||||
|
||||
class LogWindow : public QMainWindow {
|
||||
public:
|
||||
LogWindow(QWidget* parent = nullptr) : QMainWindow(parent) {
|
||||
// 创建日志框
|
||||
logTextEdit = new QTextEdit(this);
|
||||
logTextEdit->setReadOnly(true); // 设置为只读
|
||||
|
||||
// 设置主窗口布局
|
||||
setCentralWidget(logTextEdit);
|
||||
}
|
||||
|
||||
// 添加日志信息
|
||||
void addLog(const QString& message) {
|
||||
QString text = "<span style='color: yellow;'>" + getCurrentDate() + "</span> "
|
||||
"<span style='color: yellow;'>" + getCurrentTime() + "</span> "
|
||||
"<span style='color: white;'>" + message + "</span> ";
|
||||
logTextEdit->append(text);
|
||||
}
|
||||
QString getCurrentTime() {
|
||||
QTime currentTime = QTime::currentTime();
|
||||
return currentTime.toString("HH:mm:ss.zzz");
|
||||
}
|
||||
QString getCurrentDate() {
|
||||
QDate currentDate = QDate::currentDate();
|
||||
return currentDate.toString("yyyy-MM-dd");
|
||||
}
|
||||
private:
|
||||
QTextEdit* logTextEdit;
|
||||
};
|
||||
Reference in New Issue
Block a user