From ca5154d7401fdfb3738d69f00466fb98e6a472e4 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 5 Jan 2022 14:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=8C=E6=97=B6=E4=B8=8D=E6=97=B6?= =?UTF-8?q?=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ip_sacaner/scan_run.cpp | 21 ++++++++++++++------- ip_sacaner/scan_run.h | 2 +- ip_sacaner/widget.cpp | 5 ++++- ip_sacaner/widget.h | 3 ++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ip_sacaner/scan_run.cpp b/ip_sacaner/scan_run.cpp index a6273ee..435393f 100644 --- a/ip_sacaner/scan_run.cpp +++ b/ip_sacaner/scan_run.cpp @@ -29,7 +29,8 @@ quint32 ipv4str_to_int(const QString& ipstr) void trytry::run() { qDebug() << ipstr<<":"<< ipint; - *now_thread_num++; + *now_thread_num+=1; + QTcpSocket m_socket; m_socket.connectToHost(ipstr, ipint, QTcpSocket::ReadWrite); if (m_socket.waitForConnected(timeout)) @@ -39,10 +40,14 @@ void trytry::run() } m_socket.disconnectFromHost(); m_socket.disconnect(); - *now_thread_num--; - - *nt_bar++; - the_bar->setValue(((*nt_bar)/(*t_bar))*100); + *now_thread_num-=1; + + *nt_bar+=1; + //((*nt_bar)/(*t_bar))*100 + //the_bar->setValue(((0.0+*nt_bar)/(*t_bar))*100); + //qDebug()<<((0.0+*nt_bar)/(0.0+*t_bar))*100<<"%"; + //the_bar->setValue(10); + qDebug()<<*nt_bar<<"/"<<*t_bar; } dispatch::dispatch() @@ -82,6 +87,7 @@ void dispatch::run() { //qDebug()<< ui->IP_list->toPlainText(); + //the_bar->setValue(20); QTcpSocket* m_socket = new QTcpSocket; @@ -128,7 +134,8 @@ void dispatch::run() } t_bar=ips_num*ports_num; - //qDebug()<< + nt_bar=0; + //qDebug()<<*t_bar; //***************************** for (int i = 0; i < str_ip_list.size(); ++i) { @@ -192,7 +199,7 @@ void dispatch::run() } - //sleep(1);//稍微等一下其他线程完成 + sleep(1);//稍微等一下其他线程完成 emit dispatch_finish(); } diff --git a/ip_sacaner/scan_run.h b/ip_sacaner/scan_run.h index cbf4e0b..d47b884 100644 --- a/ip_sacaner/scan_run.h +++ b/ip_sacaner/scan_run.h @@ -40,7 +40,7 @@ public: quint16 set_thread_num; quint16 now_thread_num; quint16 timeout; - quint64 t_bar; + quint64 t_bar=0; quint64 nt_bar=0; QThread* main_thread; diff --git a/ip_sacaner/widget.cpp b/ip_sacaner/widget.cpp index 0e4fd49..f27db44 100644 --- a/ip_sacaner/widget.cpp +++ b/ip_sacaner/widget.cpp @@ -22,14 +22,17 @@ Widget::Widget(QWidget *parent) //qDebug("hello world"); - //ui->type_bar->setValue(10); + + main_thread = new QThread(this); main_thread->start(); connect(ui->stard_scan, &QPushButton::pressed, [=]() { + dispatch* dispatch_thread; dispatch_thread = new dispatch; + dispatch_thread->ip_list = ui->IP_list; dispatch_thread->port_list = ui->port_list; dispatch_thread->output_list = ui->outputlist; diff --git a/ip_sacaner/widget.h b/ip_sacaner/widget.h index 323de6b..8a339f7 100644 --- a/ip_sacaner/widget.h +++ b/ip_sacaner/widget.h @@ -26,7 +26,8 @@ public: QThread* main_thread; - + quint64 *t_bar; + quint64 *nt_bar; private: Ui::Widget* ui;