Files
DataStructureProject/logwindow.cpp
T
2017-12-23 20:17:59 +08:00

42 lines
795 B
C++

#include "logwindow.h"
#include "ui_logwindow.h"
#include <QTime>
LogWindow* LogWindow::m_instance = nullptr;
LogWindow::LogWindow(QWidget *parent) :
QWidget(parent, Qt::Dialog),
ui(new Ui::LogWindow)
{
ui->setupUi(this);
text = ui->text;
setWindowTitle("日志窗口");
setGeometry(parent->x() + parent->width(), y(), 400, 450);
this->hide();
setFocusPolicy(Qt::NoFocus);
}
LogWindow::~LogWindow()
{
delete ui;
}
LogWindow *LogWindow::getInstance(QWidget *parent)
{
if (m_instance == nullptr)
m_instance = new LogWindow(parent);
return m_instance;
}
void LogWindow::i(QString text)
{
getInstance()->text->append(QTime::currentTime().toString("hh:mm:ss")+":"+text);
}
LogWindow *LogWindow::getInstance()
{
return m_instance;
}