This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
qSniff/source/mainwindow.cpp

30 lines
674 B
C++

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "sniffthread.h"
#include <QTime>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->pushButton, &QPushButton::clicked, ui->listWidget, &QListWidget::clear);
SniffThread *sniffThread = new SniffThread();
connect(sniffThread, &SniffThread::dataReceived, this, &MainWindow::dataReceived);
sniffThread->start();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::dataReceived(QString data)
{
QTime currentTime = QTime::currentTime();
ui->listWidget->addItem(currentTime.toString(Qt::ISODate) + ": " + data);
}