diff --git a/.gitignore b/.gitignore index f147edf..536ae92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,52 @@ -# C++ objects and libs -*.slo -*.lo -*.o -*.a -*.la -*.lai -*.so -*.so.* -*.dll -*.dylib - -# Qt-es -object_script.*.Release -object_script.*.Debug -*_plugin_import.cpp -/.qmake.cache -/.qmake.stash -*.pro.user -*.pro.user.* -*.qbs.user -*.qbs.user.* -*.moc -moc_*.cpp -moc_*.h -qrc_*.cpp -ui_*.h -*.qmlc -*.jsc -Makefile* -*build-* -*.qm -*.prl - -# Qt unit tests -target_wrapper.* - -# QtCreator -*.autosave - -# QtCreator Qml -*.qmlproject.user -*.qmlproject.user.* - -# QtCreator CMake -CMakeLists.txt.user* - -# QtCreator 4.8< compilation database -compile_commands.json - -# QtCreator local machine specific files for imported projects -*creator.user* +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.so.* +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* +*.qm +*.prl + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +# QtCreator 4.8< compilation database +compile_commands.json + +# QtCreator local machine specific files for imported projects +*creator.user* diff --git a/01QMianWindows/01QMianWindows.pro b/01QMianWindows/01QMianWindows.pro new file mode 100644 index 0000000..86ffa66 --- /dev/null +++ b/01QMianWindows/01QMianWindows.pro @@ -0,0 +1,37 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-29T21:01:38 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 01QMianWindows +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/01QMianWindows/main.cpp b/01QMianWindows/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/01QMianWindows/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/01QMianWindows/mainwindow.cpp b/01QMianWindows/mainwindow.cpp new file mode 100644 index 0000000..3a3baed --- /dev/null +++ b/01QMianWindows/mainwindow.cpp @@ -0,0 +1,90 @@ +#include "mainwindow.h" +#include +#include +#include +#include +#include +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + + //重置窗口 + resize(600,400); + + + //创建菜单栏 + QMenuBar *menu1= menuBar(); + + //将菜单栏放入Mainwindows其中 + setMenuBar(menu1); + + + //创建一个菜单 + QMenu * file= menu1->addMenu("你好"); + QMenu * bianjie=menu1->addMenu("边界"); + + //创建菜单项目 + QAction* edit =file->addAction("编辑"); + QAction* open= file->addAction("打开"); + + + //添加分隔符 + file->addSeparator(); + file->addAction("打开1"); + + + //工具栏,可以有多个 + QToolBar *tool=new QToolBar(this); + + //放入窗口中 + addToolBar(Qt::LeftToolBarArea,tool); + + //只允许左右停靠 + tool->setAllowedAreas(Qt::RightToolBarArea | Qt::RightToolBarArea); + + //允许浮动 + tool->setFloatable(true); + + + //设置移动,总开关,无论上面设置什么 + tool->setMovable(false); + + + //设置工具栏内容 + tool->addAction("你好"); + tool->addAction(open); + //添加分割线 + tool->addSeparator(); + tool->addAction(edit); + //添加控件:按钮 + QPushButton * btn = new QPushButton("aa",this); + tool->addWidget(btn); + + + + //状态栏,只能有一个 + QStatusBar * status= new QStatusBar(this); + setStatusBar(status); + //放标签的控件 + QLabel * label =new QLabel("提示信息",this); + status->addWidget(label); + + QLabel * label1 =new QLabel("右侧提示信息",this); + status->addPermanentWidget(label1); + + + //铆接固件,围绕着核心固件 + QDockWidget * dock = new QDockWidget("浮动",this); + addDockWidget(Qt::LeftDockWidgetArea,dock); + + + //设置中心部件 + QTextEdit * edit1 = new QTextEdit(this); + setCentralWidget(edit1); + dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea); +} + +MainWindow::~MainWindow() +{ + +} diff --git a/01QMianWindows/mainwindow.h b/01QMianWindows/mainwindow.h new file mode 100644 index 0000000..ada4e17 --- /dev/null +++ b/01QMianWindows/mainwindow.h @@ -0,0 +1,16 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H +#include +#include +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +}; + +#endif // MAINWINDOW_H diff --git a/01day/01day.pro b/01day/01day.pro new file mode 100644 index 0000000..b3f57e7 --- /dev/null +++ b/01day/01day.pro @@ -0,0 +1,39 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-27T21:27:53 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 01day +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + mypushbutton.cpp + +HEADERS += \ + widget.h \ + mypushbutton.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/01day/main.cpp b/01day/main.cpp new file mode 100644 index 0000000..46305df --- /dev/null +++ b/01day/main.cpp @@ -0,0 +1,15 @@ +#include "widget.h" +#include +//argc命令行变量的数量 argv命令行变量的数组 +int main(int argc, char *argv[]) +{ + //应用程序对象 + QApplication a(argc, argv); + //窗口对象 Widget ->Qwidget + Widget w; + //窗口对象默认不显示,必须调用show方法 + w.show(); + + //让程序对象进入消息循环机制 + return a.exec(); +} diff --git a/01day/mypushbutton.cpp b/01day/mypushbutton.cpp new file mode 100644 index 0000000..81e7340 --- /dev/null +++ b/01day/mypushbutton.cpp @@ -0,0 +1,12 @@ +#include "mypushbutton.h" +#include + +MyPushButton::MyPushButton(QWidget *parent) : QPushButton(parent) +{ + qDebug()<<"我的自定义按钮"; + +} +MyPushButton::~MyPushButton() +{ + qDebug()<<"我的按钮的析构"; +} diff --git a/01day/mypushbutton.h b/01day/mypushbutton.h new file mode 100644 index 0000000..fc6ae11 --- /dev/null +++ b/01day/mypushbutton.h @@ -0,0 +1,19 @@ +#ifndef MYPUSHBUTTON_H +#define MYPUSHBUTTON_H + +#include + +class MyPushButton : public QPushButton +{ + Q_OBJECT +public: + explicit MyPushButton(QWidget *parent = nullptr); + + ~MyPushButton(); + +signals: + +public slots: +}; + +#endif // MYPUSHBUTTON_H diff --git a/01day/widget.cpp b/01day/widget.cpp new file mode 100644 index 0000000..55e554d --- /dev/null +++ b/01day/widget.cpp @@ -0,0 +1,62 @@ +#include +#include "widget.h" +#include"mypushbutton.h" +#include +//命名规则 +//类名,首字母大写,单词和单词之间首字母大写 + + + +Widget::Widget(QWidget *parent) + : QWidget(parent) //调用父类的构造,将parent传递给父类 +{ + //创建一个按钮 + QPushButton * p= new QPushButton; + p->show(); //以顶层的方式弹出 + p->setParent(this); //让p随着父类指针显示 + p->setText("第一个按钮"); + + //创建第二个按钮,父类直接传入 + QPushButton *btn2= new QPushButton("第二个按钮",this); + btn2->move(100,100); //移动到100,100的位置 + + + //按钮指定大小 + btn2->resize(100,100); + + + //重置窗口大小 + resize(600,400); + + + //设置固定的窗口大小 + setFixedSize(600,400); + + //设置窗口的标题 + setWindowTitle("第一个窗口"); + + + //创建一个自己按钮的对象 + MyPushButton * btn3= new MyPushButton(); + btn3->setText("你好"); + btn3->move(200,200); + btn3->setParent(this); + + + //我点击一下按钮,关闭窗口 + //参数一:信号的发送者;参数二:发送的信号(函数地址); + //参数三:信号的接受者;参数四:信号处理函数(函数地址) + connect(btn3,&QPushButton::clicked,this,&Widget::close); + //要使用静态函数的方式去传递函数 + + + + +} + +Widget::~Widget() +{ + qDebug()<<"MyWidget析构"; + //先去寻找自己挂载的对象 + +} diff --git a/01day/widget.h b/01day/widget.h new file mode 100644 index 0000000..0eda35f --- /dev/null +++ b/01day/widget.h @@ -0,0 +1,18 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include //包含Qwidget窗口类 + +class Widget : public QWidget +{ + Q_OBJECT //Q_OBJECT宏,使之可以用信号和槽机制 + +public: + Widget(QWidget *parent = 0); //构造函数 + ~Widget(); +}; + +#endif // WIDGET_H + + + diff --git a/02/02/02.pro b/02/02/02.pro new file mode 100644 index 0000000..060921d --- /dev/null +++ b/02/02/02.pro @@ -0,0 +1,44 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-28T22:19:07 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 02 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + singleslot.cpp \ + teacher.cpp \ + student.cpp + +HEADERS += \ + singleslot.h \ + teacher.h \ + student.h + +FORMS += \ + singleslot.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/02/02/main.cpp b/02/02/main.cpp new file mode 100644 index 0000000..288d033 --- /dev/null +++ b/02/02/main.cpp @@ -0,0 +1,11 @@ +#include "singleslot.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + SingleSlot w; + w.show(); + + return a.exec(); +} diff --git a/02/02/singleslot.cpp b/02/02/singleslot.cpp new file mode 100644 index 0000000..9e3c7b6 --- /dev/null +++ b/02/02/singleslot.cpp @@ -0,0 +1,126 @@ +#include "singleslot.h" +#include "ui_singleslot.h" +#include + +//自定义信号和槽 + +//teacher 类 +//student 类 +//需求:下课后,老师说饿了,学生请客吃饭 + + +SingleSlot::SingleSlot(QWidget *parent) : + QWidget(parent), + ui(new Ui::SingleSlot) +{ + ui->setupUi(this);//ui设计函数,不用管 + + //创建老师对象 + zt= new Teacher(this);//指明他们的父亲 + + + //创建学生对象 + st = new Student(this); + + //老师饿了,学生请客 +// connect(zt,&Teacher::hungry,st,&Student::Treat); +// classover(); +// classover2(); + //也就是说,以后再调用zt的hungry的同时,自动调用student::treat + //为什么要传入对象?信号和槽机制主要是想知道是谁调用的,谁回答的 + + + + + //连接带参数的信号和槽 + //重载的时候一定要去除函数地址的二义性 + //使用函数指针指向地址 + //声明函数指针解决重载的问题 + void(Teacher::*teachersignal)(QString)=&Teacher::hungry;//需要函数作用域Teacher + void(Student::*Studentslot)(QString)=&Student::Treat; + + //连接信号和槽 + connect(zt,teachersignal,st,Studentslot); + classover(); + + + + //点击一个按钮,再下课 + setFixedSize(600,400); + QPushButton *btn1= new QPushButton("Class Over",this); + + //固定窗口的大小 + setFixedSize(800,500); + btn1->resize(100,50); + btn1->move(100,200); + + //点击按钮,触发下课 + connect(btn1,&QPushButton::clicked,this,&SingleSlot::classover); + + //无参的信号和槽的连接(重载的情况下) + void (Student::* st1)(void)=&Student::Treat; + void (Teacher:: *zt1)(void)=&Teacher::hungry; + + QPushButton *btn2=new QPushButton("classover2",this); + btn2->resize(100,50); + btn2->move(400,200); + + //将信号和槽的关系,定义了zt和st的关系 + connect(zt,zt1,st,st1); + + //用原始的信号和函数的调用 +// connect(btn2,&QPushButton::clicked,this,&SingleSlot::classover2); + + + //信号连接信号 + //connect(btn2,&QPushButton::clicked,zt,zt1); + + //connect(btn2,&QPushButton::clicked,zt,teachersignal); + //断开信号:disconnect(对象一,类的函数地址,对象二,类的槽函数地址) +// disconnect(btn2,&QPushButton::clicked,zt,zt1); + + + //拓展 + //一个信号多个槽函数 + connect(btn2,&QPushButton::clicked,this,&SingleSlot::close); + + + //多个信号连接一个槽函数 + connect(btn1,&QPushButton::clicked,this,&SingleSlot::close); + + //匿名函数 +// [btn1]() +// { +// btn1->setText("nihao"); +// btn2->setText("nihao"); +// }(); + + //mutable修饰值传递,修改拷贝 + int m=10; + connect(btn1,&QPushButton::clicked,this,[m]()mutable{m++;qDebug()<move(250,250); + connect(btn3,&QPushButton::clicked,this,[=](){ + //this->close(); + st->Treat("麻辣鸭池"); + btn3->setText("aaa"); + }); +} + +SingleSlot::~SingleSlot() +{ + delete ui; +} +void SingleSlot::classover() +{ + // zt->hungry(); + zt->hungry("宫保鸡丁"); //这个参数也会直接传递到st的函数之中 + +} + +void SingleSlot::classover2() +{ + emit zt->hungry(); //emit要不要无所谓 +} diff --git a/02/02/singleslot.h b/02/02/singleslot.h new file mode 100644 index 0000000..d836ca7 --- /dev/null +++ b/02/02/singleslot.h @@ -0,0 +1,27 @@ +#ifndef SINGLESLOT_H +#define SINGLESLOT_H +#include"student.h" +#include"teacher.h" +#include +#include +namespace Ui { +class SingleSlot; +} + +class SingleSlot : public QWidget +{ + Q_OBJECT + +public: + explicit SingleSlot(QWidget *parent = nullptr); + ~SingleSlot(); + Teacher *zt; + Student *st; + void classover2(); + void classover(); + +private: + Ui::SingleSlot *ui; +}; + +#endif // SINGLESLOT_H diff --git a/02/02/singleslot.ui b/02/02/singleslot.ui new file mode 100644 index 0000000..1902b06 --- /dev/null +++ b/02/02/singleslot.ui @@ -0,0 +1,20 @@ + + SingleSlot + + + + 0 + 0 + 400 + 300 + + + + SingleSlot + + + + + + + diff --git a/02/02/student.cpp b/02/02/student.cpp new file mode 100644 index 0000000..3b553d4 --- /dev/null +++ b/02/02/student.cpp @@ -0,0 +1,18 @@ +#include "student.h" +#include +Student::Student(QObject *parent) : QObject(parent) +{ + +} + +void Student::Treat() +{ + + qDebug()<<"请老师吃饭"; +} + +void Student::Treat(QString foodname) +{ + //QString->char,先转QbyteArray(.toUtf8()),再使用data()转char * () + qDebug()< + +class Student : public QObject +{ + Q_OBJECT +public: + explicit Student(QObject *parent = nullptr); + //Slots函数可以写在这里 +signals: + +public slots: + //Slots函数可以写在这里 + //返回值是void,需要声明,需要实现,可以有参数,可以重载 + + void Treat(); + void Treat(QString foodname); + +}; + +#endif // STUDENT_H diff --git a/02/02/teacher.cpp b/02/02/teacher.cpp new file mode 100644 index 0000000..fb5af75 --- /dev/null +++ b/02/02/teacher.cpp @@ -0,0 +1,6 @@ +#include "teacher.h" + +Teacher::Teacher(QObject *parent) : QObject(parent) +{ + +} diff --git a/02/02/teacher.h b/02/02/teacher.h new file mode 100644 index 0000000..284709f --- /dev/null +++ b/02/02/teacher.h @@ -0,0 +1,23 @@ +#ifndef TEACHER_H +#define TEACHER_H + +#include + +class Teacher : public QObject +{ + Q_OBJECT +public: + explicit Teacher(QObject *parent = nullptr); + +signals: + //自定义信号 + //返回值是void,只需要声明,不需要实现 + //可以有参数,可以重载 + void hungry(); + + void hungry(QString foodname); //可以重载,但是这个函数一定不用实现!!! + +public slots: +}; + +#endif // TEACHER_H diff --git a/07/07.pro b/07/07.pro new file mode 100644 index 0000000..71f0f06 --- /dev/null +++ b/07/07.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-01T19:16:53 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 07 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/07/main.cpp b/07/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/07/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/07/widget.cpp b/07/widget.cpp new file mode 100644 index 0000000..5266452 --- /dev/null +++ b/07/widget.cpp @@ -0,0 +1,38 @@ +#include "widget.h" +#include "ui_widget.h" + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //TableWidget + //设置一下列数 + ui->tableWidget->setColumnCount(3); + //设置表头 + ui->tableWidget->setHorizontalHeaderLabels(QStringList()<<"姓名"<<"性别"<<"年龄"); + //设置行数 + ui->tableWidget->setRowCount(5); + + //设置正文 + QStringList nameList; + nameList<<"亚瑟"<<"张飞"<<"关羽"<<"花木兰"<<"uz"; + + //设置性别 + QList sexList; + sexList<<"f"<<"m"<<"f"<<"f"<<"f"; + ui->tableWidget->setItem(0,0,new QTableWidgetItem("亚瑟")); + for(int i=0;i<5;i++) + { + int col =0; + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i])); + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(sexList.at(i))); + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(QString::number(i+18))); + } + +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/07/widget.h b/07/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/07/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/07/widget.ui b/07/widget.ui new file mode 100644 index 0000000..309b54c --- /dev/null +++ b/07/widget.ui @@ -0,0 +1,25 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + + + + + + + diff --git a/08/08.pro b/08/08.pro new file mode 100644 index 0000000..ea03301 --- /dev/null +++ b/08/08.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-01T19:32:51 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = 08 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + res.qrc diff --git a/08/image/C.png b/08/image/C.png new file mode 100644 index 0000000..7bdc74f Binary files /dev/null and b/08/image/C.png differ diff --git a/08/image/Office.png b/08/image/Office.png new file mode 100644 index 0000000..caec635 Binary files /dev/null and b/08/image/Office.png differ diff --git a/08/image/R.gif b/08/image/R.gif new file mode 100644 index 0000000..11eb515 Binary files /dev/null and b/08/image/R.gif differ diff --git a/08/image/cpp.png b/08/image/cpp.png new file mode 100644 index 0000000..973d118 Binary files /dev/null and b/08/image/cpp.png differ diff --git a/08/image/jie.jpg b/08/image/jie.jpg new file mode 100644 index 0000000..a572ce8 Binary files /dev/null and b/08/image/jie.jpg differ diff --git a/08/image/youtube-logo_1647079616164.png b/08/image/youtube-logo_1647079616164.png new file mode 100644 index 0000000..6531f1a Binary files /dev/null and b/08/image/youtube-logo_1647079616164.png differ diff --git a/08/jie.jpg b/08/jie.jpg new file mode 100644 index 0000000..a572ce8 Binary files /dev/null and b/08/jie.jpg differ diff --git a/08/main.cpp b/08/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/08/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/08/res.qrc b/08/res.qrc new file mode 100644 index 0000000..db6f173 --- /dev/null +++ b/08/res.qrc @@ -0,0 +1,10 @@ + + + image/C.png + image/cpp.png + image/jie.jpg + image/Office.png + image/R.gif + image/youtube-logo_1647079616164.png + + diff --git a/08/widget.cpp b/08/widget.cpp new file mode 100644 index 0000000..f6a69df --- /dev/null +++ b/08/widget.cpp @@ -0,0 +1,47 @@ +#include "widget.h" +#include "ui_widget.h" + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //栈控件 + //scrollArea + + //设置默认第一个页面 + ui->tabWidget->setCurrentIndex(1); + + connect(ui->Btn1,&QPushButton::clicked,[=]() + { + ui->tabWidget->setCurrentIndex(1); + }); + + connect(ui->Btn2,&QPushButton::clicked,[=]() + { + ui->tabWidget->setCurrentIndex(0); + }); + + //下拉框 + ui->comboBox->addItem("宝马"); + ui->comboBox->addItem("奔驰"); + ui->comboBox->addItem("哥的"); + + //点击按钮选择哥的 + connect(ui->select,&QPushButton::clicked,[=]() + { + //ui->comboBox->setCurrentIndex(2); + ui->comboBox->setCurrentText("哥的"); + }); + + //利用label + ui->label->setPixmap(QPixmap(":/image/cpp.png")); + QMovie *movie = new QMovie(":/image/R.gif"); + ui->label_2->setMovie(movie); + movie->start(); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/08/widget.h b/08/widget.h new file mode 100644 index 0000000..157d647 --- /dev/null +++ b/08/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H +#include +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/08/widget.ui b/08/widget.ui new file mode 100644 index 0000000..2fbe3af --- /dev/null +++ b/08/widget.ui @@ -0,0 +1,271 @@ + + + Widget + + + + 0 + 0 + 1300 + 628 + + + + Widget + + + + + 40 + 60 + 371 + 311 + + + + 0 + + + + Tab 1 + + + + + 0 + 0 + 361 + 281 + + + + 3 + + + + + 0 + 0 + 361 + 161 + + + + Page 1 + + + + + + 0 + 0 + 361 + 161 + + + + Page 2 + + + + + + 0 + 0 + 361 + 161 + + + + + + + + + + 0 + 0 + 361 + 161 + + + + + + + + + + + Tab 2 + + + + + 0 + 0 + 361 + 321 + + + + true + + + + + 0 + 0 + 338 + 330 + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + + + + + + 430 + 80 + 121 + 41 + + + + PushButton + + + + + + 430 + 160 + 121 + 41 + + + + PushButton + + + + + + 650 + 40 + 87 + 22 + + + + + + + 660 + 150 + 93 + 28 + + + + PushButton + + + + + + 20 + 390 + 381 + 251 + + + + TextLabel + + + + + + 940 + 140 + 381 + 251 + + + + TextLabel + + + + + + + diff --git a/QT_Dialog/QT_Dialog.pro b/QT_Dialog/QT_Dialog.pro new file mode 100644 index 0000000..55cb3a6 --- /dev/null +++ b/QT_Dialog/QT_Dialog.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-29T22:14:14 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = QT_Dialog +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/QT_Dialog/main.cpp b/QT_Dialog/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/QT_Dialog/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/QT_Dialog/mainwindow.cpp b/QT_Dialog/mainwindow.cpp new file mode 100644 index 0000000..8ce24a8 --- /dev/null +++ b/QT_Dialog/mainwindow.cpp @@ -0,0 +1,37 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + //点击新建按钮,弹出对话框 + connect(ui->actionnew,&QAction::triggered,this,[=]() + { + //弹出对话框 模态(不可对其他窗口进行操作),非模态(可以操作其他窗口); + QDialog dlg(this); + dlg.resize(200,100); + + dlg.exec();//模态 + + qDebug()<<"模态"; + }); + + //非模态 + connect(ui->actionfilw,&QAction::triggered,this,[=]() + { +// QDialog dlg(this);//这样不行,栈上的会自动释放 + QDialog* dialog = new QDialog(this); //关闭时没有释放内存 + dialog->resize(200,100); + dialog->show(); + dialog->setAttribute(Qt::WA_DeleteOnClose); + + }); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/QT_Dialog/mainwindow.h b/QT_Dialog/mainwindow.h new file mode 100644 index 0000000..1df1cfa --- /dev/null +++ b/QT_Dialog/mainwindow.h @@ -0,0 +1,23 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H +#include +#include +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/QT_Dialog/mainwindow.ui b/QT_Dialog/mainwindow.ui new file mode 100644 index 0000000..737a88d --- /dev/null +++ b/QT_Dialog/mainwindow.ui @@ -0,0 +1,70 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + 0 + 0 + 400 + 26 + + + + + new + + + + + + + + edit + + + + + + + + TopToolBarArea + + + false + + + + + + file + + + + + new + + + + + this + + + + + + + diff --git a/Q_Tree/Q_Tree.pro b/Q_Tree/Q_Tree.pro new file mode 100644 index 0000000..8ea37b9 --- /dev/null +++ b/Q_Tree/Q_Tree.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-01T17:17:01 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Q_Tree +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/Q_Tree/main.cpp b/Q_Tree/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/Q_Tree/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/Q_Tree/widget.cpp b/Q_Tree/widget.cpp new file mode 100644 index 0000000..6adafba --- /dev/null +++ b/Q_Tree/widget.cpp @@ -0,0 +1,33 @@ +#include "widget.h" +#include "ui_widget.h" +#include +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //i->treeView->setHeader(); + ui->treeWidget->setHeaderLabels(QStringList()<<"英雄"<<"英雄简介"); + QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()<<"力量"); + QTreeWidgetItem *item1 = new QTreeWidgetItem(QStringList()<<"危险"); + QTreeWidgetItem *item2 = new QTreeWidgetItem(QStringList()<<"错误"); + //加载顶层结点 + ui->treeWidget->addTopLevelItem(item); + ui->treeWidget->addTopLevelItem(item1); + ui->treeWidget->addTopLevelItem(item2); + + //追加子节点 + QStringList hero1; + hero1<<"刚被猪"<<"前排坦克"; + QTreeWidgetItem *h = new QTreeWidgetItem(hero1); + item->addChild(h); + + + + +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/Q_Tree/widget.h b/Q_Tree/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/Q_Tree/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/Q_Tree/widget.ui b/Q_Tree/widget.ui new file mode 100644 index 0000000..0507160 --- /dev/null +++ b/Q_Tree/widget.ui @@ -0,0 +1,31 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + + + 1 + + + + + + + + + + diff --git a/Qpixmap/Qpixmap.pro b/Qpixmap/Qpixmap.pro new file mode 100644 index 0000000..ad08ba1 --- /dev/null +++ b/Qpixmap/Qpixmap.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T12:03:24 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Qpixmap +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + image/res.qrc diff --git a/Qpixmap/image/C.png b/Qpixmap/image/C.png new file mode 100644 index 0000000..7bdc74f Binary files /dev/null and b/Qpixmap/image/C.png differ diff --git a/Qpixmap/image/Office.png b/Qpixmap/image/Office.png new file mode 100644 index 0000000..caec635 Binary files /dev/null and b/Qpixmap/image/Office.png differ diff --git a/Qpixmap/image/R.gif b/Qpixmap/image/R.gif new file mode 100644 index 0000000..11eb515 Binary files /dev/null and b/Qpixmap/image/R.gif differ diff --git a/Qpixmap/image/cpp.png b/Qpixmap/image/cpp.png new file mode 100644 index 0000000..973d118 Binary files /dev/null and b/Qpixmap/image/cpp.png differ diff --git a/Qpixmap/image/jie.jpg b/Qpixmap/image/jie.jpg new file mode 100644 index 0000000..a572ce8 Binary files /dev/null and b/Qpixmap/image/jie.jpg differ diff --git a/Qpixmap/image/res.qrc b/Qpixmap/image/res.qrc new file mode 100644 index 0000000..79877c8 --- /dev/null +++ b/Qpixmap/image/res.qrc @@ -0,0 +1,10 @@ + + + C.png + cpp.png + jie.jpg + Office.png + R.gif + youtube-logo_1647079616164.png + + diff --git a/Qpixmap/image/youtube-logo_1647079616164.png b/Qpixmap/image/youtube-logo_1647079616164.png new file mode 100644 index 0000000..6531f1a Binary files /dev/null and b/Qpixmap/image/youtube-logo_1647079616164.png differ diff --git a/Qpixmap/main.cpp b/Qpixmap/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/Qpixmap/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/Qpixmap/widget.cpp b/Qpixmap/widget.cpp new file mode 100644 index 0000000..df6be81 --- /dev/null +++ b/Qpixmap/widget.cpp @@ -0,0 +1,67 @@ +#include "widget.h" +#include "ui_widget.h" +#include +#include +#include +#include + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //pixmap绘图 + + //填充颜色 + +// QPixmap pix(400,400); +// pix.fill(Qt::white); +// QPainter painter(&pix); +// painter.drawEllipse(QPoint(150,150),20,20); + +// pix.save("D:\\pix.png"); + + //Qimage 绘图设备 + //QImage img(300,300,QImage::Format_RGB32); + + + //Qpicture 绘图设备 可以记录和重现绘图的指令 + QPicture pic; + QPainter painter; + painter.begin(&pic); + painter.setPen(Qt::blue); + painter.drawEllipse(QPoint(150,150),100,100); + + + painter.end(); + + //保存 + pic.save("D:\\1.png"); + +} +void Widget::paintEvent(QPaintEvent *) +{ +// //像素点修改 +// QPainter painter(this); +// QImage img; +// img.load(":/C.png"); +// for (int i =50;i<100;i++) +// { +// for(int j=50;j<100;j++) +// { +// QRgb value =qRgb(255,0,0); +// img.setPixel(i,j,value); +// } +// } +// painter.drawImage(0,0,img); + QPainter painter(this); + //重新绘图指令 + QPicture pic; + pic.load("D:\\1.png"); + painter.drawPicture(0,0,pic); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/Qpixmap/widget.h b/Qpixmap/widget.h new file mode 100644 index 0000000..94d2fdd --- /dev/null +++ b/Qpixmap/widget.h @@ -0,0 +1,23 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + void paintEvent(QPaintEvent *); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/Qpixmap/widget.ui b/Qpixmap/widget.ui new file mode 100644 index 0000000..8c91283 --- /dev/null +++ b/Qpixmap/widget.ui @@ -0,0 +1,20 @@ + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + + + diff --git a/Qt_event/Qt_event.pro b/Qt_event/Qt_event.pro new file mode 100644 index 0000000..88cc64a --- /dev/null +++ b/Qt_event/Qt_event.pro @@ -0,0 +1,42 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:49:56 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Qt_event +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + mylabel.cpp + +HEADERS += \ + widget.h \ + mylabel.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/Qt_event/main.cpp b/Qt_event/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/Qt_event/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/Qt_event/mylabel.cpp b/Qt_event/mylabel.cpp new file mode 100644 index 0000000..fc1733d --- /dev/null +++ b/Qt_event/mylabel.cpp @@ -0,0 +1,49 @@ +#include "mylabel.h" +#include"QDebug" +mylabel::mylabel(QWidget * parent):QLabel(parent) +{ + //设置鼠标追踪 + setMouseTracking(true); +} + +//鼠标进入 +void mylabel::enterEvent(QEvent *event) +{ + qDebug()<<"鼠标进入"; +} + + +//鼠标离开 +void mylabel::leaveEvent(QEvent *event) +{ + qDebug()<<"鼠标离开"; +} + + +//鼠标按下 +void mylabel::mousePressEvent(QMouseEvent *ev) +{ + //左键按下,提示这些 + if(ev->button()==Qt::LeftButton) + {QString str =QString("鼠标按下 x=%1 y=%2").arg(ev->x()).arg(ev->y()); + qDebug()<button()==Qt::LeftButton) + {qDebug()<<"鼠标释放";} +} + +//鼠标重写 +void mylabel::mouseMoveEvent(QMouseEvent *ev) +{ +// if(ev->buttons() && Qt::LeftButton) +// { + QString str =QString("鼠标移动 x=%1 y=%2").arg(ev->x()).arg(ev->y()); + qDebug()< +#include +#include +class mylabel: public QLabel +{ +public: + explicit mylabel(QWidget * parent=0); + + //鼠标进入 + void enterEvent(QEvent *event); + + //鼠标离开 + void leaveEvent(QEvent *event); + + + //鼠标按下 + virtual void mousePressEvent(QMouseEvent *ev); + //鼠标释放 + virtual void mouseReleaseEvent(QMouseEvent *ev); + + //鼠标重写 + virtual void mouseMoveEvent(QMouseEvent *ev); + + //bool event(QEvent *e); + + + + +}; + +#endif // MYLABEL_H diff --git a/Qt_event/widget.cpp b/Qt_event/widget.cpp new file mode 100644 index 0000000..b581488 --- /dev/null +++ b/Qt_event/widget.cpp @@ -0,0 +1,71 @@ +#include "widget.h" +#include "ui_widget.h" +#include +#include +#include +using namespace std; +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //启动定时器 + id1 = startTimer(1000);//参数1,间隔 + id2 = startTimer(2000); + + + //定时器的第二种方式 + QTimer *timer= new QTimer(this); + + //启动定时器 + timer->start(500); + + connect(timer,&QTimer::timeout,[=]() + { + static int number =1; + cout<label_4->setText(QString::number(number++)); + + }); + + + //给label1安装事件过滤器 + ui->label->installEventFilter(this); + //重写eventfilter + +} + +bool Widget::eventFilter(QObject *obj, QEvent *e) +{ + if(obj==ui->label) + { + if(e->type()==QEvent::MouseButtonPress) + { + QMouseEvent * ev = static_cast(e); + QString str =QString("event 鼠标按下 x=%1 y=%2").arg(ev->x()).arg(ev->y()); + qDebug()<timerId()==id1) + { + static int number =1; + cout<label_2->setText(QString::number(number++)); + } + if(p->timerId()==id2) + { + static int num2 = 1; + ui->label_3->setText(QString::number(num2++)); + } + +} diff --git a/Qt_event/widget.h b/Qt_event/widget.h new file mode 100644 index 0000000..ae0d6f3 --- /dev/null +++ b/Qt_event/widget.h @@ -0,0 +1,27 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + //重新写定时器 + void timerEvent(QTimerEvent *); + + //重写时间过滤器的事件 + bool eventFilter(QObject *watched, QEvent *event); +private: + Ui::Widget *ui; + int id1,id2; +}; + +#endif // WIDGET_H diff --git a/Qt_event/widget.ui b/Qt_event/widget.ui new file mode 100644 index 0000000..35b7946 --- /dev/null +++ b/Qt_event/widget.ui @@ -0,0 +1,91 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + 120 + 20 + 171 + 121 + + + + QFrame::Panel + + + + + + + + + 120 + 150 + 171 + 31 + + + + QFrame::Panel + + + + + + + + + 120 + 190 + 171 + 31 + + + + QFrame::Panel + + + + + + + + + 120 + 240 + 171 + 31 + + + + QFrame::Panel + + + + + + + + + + mylabel + QLabel +
mylabel.h
+
+
+ + +
diff --git a/Qthre/Qthre.pro b/Qthre/Qthre.pro new file mode 100644 index 0000000..a9e180b --- /dev/null +++ b/Qthre/Qthre.pro @@ -0,0 +1,39 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-04T19:43:09 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Qthre +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + mythread.cpp + +HEADERS += \ + widget.h \ + mythread.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/Qthre/main.cpp b/Qthre/main.cpp new file mode 100644 index 0000000..cddfdc9 --- /dev/null +++ b/Qthre/main.cpp @@ -0,0 +1,14 @@ +#include "widget.h" +#include +#include +#include +int main(int argc, char *argv[]) +{ +// QApplication a(argc, argv); +// Widget w; +// w.show(); + +// return a.exec(); + + +} diff --git a/Qthre/mythread.cpp b/Qthre/mythread.cpp new file mode 100644 index 0000000..50602a8 --- /dev/null +++ b/Qthre/mythread.cpp @@ -0,0 +1,6 @@ +#include "mythread.h" + +mythread::mythread() +{ + +} diff --git a/Qthre/mythread.h b/Qthre/mythread.h new file mode 100644 index 0000000..9b7cb4b --- /dev/null +++ b/Qthre/mythread.h @@ -0,0 +1,11 @@ +#ifndef MYTHREAD_H +#define MYTHREAD_H +#include + +class mythread:public QThread +{ +public: + mythread(); +}; + +#endif // MYTHREAD_H diff --git a/Qthre/widget.cpp b/Qthre/widget.cpp new file mode 100644 index 0000000..2258253 --- /dev/null +++ b/Qthre/widget.cpp @@ -0,0 +1,11 @@ +#include "widget.h" + +Widget::Widget(QWidget *parent) + : QWidget(parent) +{ +} + +Widget::~Widget() +{ + +} diff --git a/Qthre/widget.h b/Qthre/widget.h new file mode 100644 index 0000000..7bdeac7 --- /dev/null +++ b/Qthre/widget.h @@ -0,0 +1,15 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = 0); + ~Widget(); +}; + +#endif // WIDGET_H diff --git a/README.assets/image-20220327213933097.png b/README.assets/image-20220327213933097.png new file mode 100644 index 0000000..30e67d6 Binary files /dev/null and b/README.assets/image-20220327213933097.png differ diff --git a/README.assets/image-20220329091008356.png b/README.assets/image-20220329091008356.png new file mode 100644 index 0000000..f9ac6bb Binary files /dev/null and b/README.assets/image-20220329091008356.png differ diff --git a/README.assets/image-20220329211542634.png b/README.assets/image-20220329211542634.png new file mode 100644 index 0000000..e3be88f Binary files /dev/null and b/README.assets/image-20220329211542634.png differ diff --git a/README.assets/image-20220329220719213.png b/README.assets/image-20220329220719213.png new file mode 100644 index 0000000..d82e173 Binary files /dev/null and b/README.assets/image-20220329220719213.png differ diff --git a/README.assets/image-20220329220757140.png b/README.assets/image-20220329220757140.png new file mode 100644 index 0000000..2fc1412 Binary files /dev/null and b/README.assets/image-20220329220757140.png differ diff --git a/README.assets/image-20220329220821362.png b/README.assets/image-20220329220821362.png new file mode 100644 index 0000000..2b62121 Binary files /dev/null and b/README.assets/image-20220329220821362.png differ diff --git a/README.assets/image-20220329221253553.png b/README.assets/image-20220329221253553.png new file mode 100644 index 0000000..cbb4d3d Binary files /dev/null and b/README.assets/image-20220329221253553.png differ diff --git a/README.assets/image-20220329221307593.png b/README.assets/image-20220329221307593.png new file mode 100644 index 0000000..bcc5584 Binary files /dev/null and b/README.assets/image-20220329221307593.png differ diff --git a/README.assets/image-20220401193159148.png b/README.assets/image-20220401193159148.png new file mode 100644 index 0000000..84d0a67 Binary files /dev/null and b/README.assets/image-20220401193159148.png differ diff --git a/README.md b/README.md index 21990d5..840ded4 100644 --- a/README.md +++ b/README.md @@ -1 +1,410 @@ -# Qt \ No newline at end of file +--- +title:Qt学习 +--- + +# day1 + +QWidget 是 QmainWindow和Qdialog的父类 + +* Qwidget为空窗口 +* Qmainwindow多了菜单栏,状态栏 +* Qdialog有一些对话框 + +## Qt.pro文件 + +* ```cpp + QT += core gui Qt包含的模块,此处为图像界面模块 + ``` + +![image-20220327213933097](E:\Qt Learnning\README.assets\image-20220327213933097.png) + +```cpp +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets //大于4版本以上多余widgets模块 +TARGET = 01day //生成exe文件的名称 +TEMPLATE = app //模板:应用程序模板 + + +SOURCES += \ + main.cpp \ + widget.cpp //源文件 + +HEADERS += \ + widget.h //头文件 +``` + + + +## 按钮和窗口 + +```cpp + //创建一个按钮 + QPushButton * p= new QPushButton; + p->show(); //以顶层的方式弹出 + p->setParent(this); //让p随着父类指针显示 + p->setText("第一个按钮"); + + //创建第二个按钮,父类直接传入 + QPushButton *btn2= new QPushButton("第二个按钮",this); + btn2->move(100,100); //移动到100,100的位置 + + //按钮指定大小 + btn2->resize(100,100); + + + //重置窗口大小 + resize(600,400); + + + //设置固定的窗口大小 + setFixedSize(600,400); + + //设置窗口的标题 + setWindowTitle("第一个窗口"); +``` + +## 对象树 + +* Qobject派生的类,可以将子类对象挂在树上,可以不用管理释放的操作,他会自动放入对象树上,简化了内存回收机制 + +* 窗口坐标系,左上角是(0,0),X向右增加,Y向下增加 + +## 信号和槽 + +```cpp +connect(信号的发送者,发送的信号,信号的接受者,信号的处理(槽函数)) +``` + +信号槽的优点:松散耦合,信号发生和接受端没有关系,通过connect连接 + +* 创建类的时候可以继承Qobject,这样可以不用管内存回收 + + + + + +信号要创建在类的`signals`里面 + +```cpp +signals: + //自定义信号 + //返回值是void,只需要声明,不需要实现 + //可以有参数,可以重载 + void hungry(); +``` + + + +槽函数创建再`slots`里面 + +```cpp +public slots: + //Slots函数可以写在这里 + //返回值是void,需要声明,需要实现,可以有参数,可以重载 + + void Treat(); + +...Treat实现 +``` + + + + + + +```cpp +//自定义信号和槽 +//teacher 类 +//student 类 +//需求:下课后,老师说饿了,学生请客吃饭 + + //创建老师对象 + zt= new Teacher(this);//指明他们的父亲 + + + //创建学生对象 + st = new Student(this); + + //老师饿了,学生请客 + connect(zt,&Teacher::hungry,st,&Student::Treat); + classover(); + classover2(); + //也就是说,以后再调用zt的hungry的同时,自动调用student::treat + //为什么要传入对象?信号和槽机制主要是想知道是谁调用的,谁回答的 +void SingleSlot::classover() +{ + zt->hungry(); +} +``` + +### 自定义信号和槽 + +实现函数重载,其中重载函数的调用方式因为会产生二义性,那么需要我们对函数使用指针进行指定 + +```cpp +//定义一个指向函数的指针 +void(Student::*Studentslot)(QString)=&Student::Treat; +void(Teacher::*teachersignal)(QString)=&Teacher::hungry; + +connect(zt,teachersignal,st,Studentslot); +zt->hungry("宫保鸡丁"); +//上面的"宫保鸡丁"也会被传入Studentslot +``` + + + +QString 转char * + +先转QbyteArray(toUtf8Array()),再用data() + +![image-20220329091008356](E:\Qt Learnning\README.assets\image-20220329091008356.png) + + + +### 信号连接信号 + +* 方式一,信号连接窗口类的函数,然后再槽函数中调用其他对象的信号,利用对象和对象的槽函数连接,对其进行控制 + +```cpp + //点击按钮,触发下课、调用classover ,然后在classover中调用zt->hungry("宫保鸡丁"); + connect(btn1,&QPushButton::clicked,this,&SingleSlot::classover); +``` + +```mermaid +graph LR + 按钮--信号到槽函数-->p1[class Over 函数]-->p2[调用zt->hungry]-->p3[调用st->Treat] +``` + + + +* 将信号和信号相连接,将信号当作槽来使用 + +```cpp + //信号连接信号 + connect(btn2,&QPushButton::clicked,zt,zt1); //zt1 是zt->hungry的指针 +``` + +思考分析 + +```mermaid +graph LR + p[按钮]--信号到信号-->q1[zt->hungry] + q1--信号到槽函数-->q2[st->Treat] + +``` + +* 断开信号 + +`disconnect` + +* 信号可以连接多个槽 +* 槽函数可以被多个信号连接,但是参数要对应 + +* 信号和槽一一对应 + +信号是有参的,那么槽函数也要是有参的 + +```cpp + void (Student::* st1)(void)=&Student::Treat; + void (Teacher:: *zt1)(void)=&Teacher::hungry; +``` + +上面这个可以连接 + +```cpp + void(Teacher::*teachersignal)(QString)=&Teacher::hungry;//需要函数作用域Teacher + void (Teacher:: *zt1)(void)=&Teacher::hungry; +``` + +下面这个不可连接,因为他们一个是`QString`,一个是`void` + +* 信号函数参数的个数可以多余槽函数的参数的个数,但是类型也要一一对应 + +信号的参数个数不能少于槽函数的类型个数,这个机制决定clicked函数了当有参构造的时候,必须使用函数调用的方法 + +```cpp +QPushButton 函数clicked()无法连接带参槽函数 +``` + +## lamabda表达式 + +语法结构 + +```cpp +[=]()//值传递,所有局部遍历都是赋值传递"="值传递,"&"引用传递 +{ + btn1->setText("nihao"); +}();//这里的小括号是调用 +``` + +```cpp +[btn1]()//当中括号是某一个变量的时候,只会值传递该值,其他变量的值不可见 +{ + btn1->setText("nihao"); + btn2->setText("nihao"); //报错,看不到btn2 +}(); +``` + +`mutable` + +```cpp +int m=10; +connect(btn1,&QPushButton::clicked,this,[m]()mutable{m++;qDebug()< m的拷贝,本身没有变 + + + +* 函数返回值,在小括号后面加上`->返回类型` + +```cpp +[btn1]()->int +{ + int m=100; + return m; +}(); +``` + +lambda表达式作为槽函数的时候可以省略第三个参数`this` + +# day2 + +## 窗口设计 + +创建QmainWindow的类模板 + +### 菜单栏 + +```cpp +//创建菜单栏 +QMenuBar *menu1= menuBar(); +``` + +类时setparent,放入窗口中 + +```cpp +//将菜单栏放入Mainwindows其中 +setMenuBar(menu1); +``` + +在菜单栏中添加一个菜单 + +```cpp +//创建一个菜单 +QMenu * file= menu1->addMenu("你好"); +QMenu * bianjie=menu1->addMenu("边界"); + +//创建菜单项目 +file->addAction("编辑"); +file->addAction("打开"); + + +//添加分隔符 +file->addSeparator(); +file->addAction("打开1"); +``` + +![image-20220329211542634](E:\Qt Learnning\README.assets\image-20220329211542634.png) + +效果如上 + +### 工具栏 + +```cpp +//工具栏,可以有多个 +QToolBar *tool=new QToolBar(this); + +//放入窗口中,默认左边,查帮助文档 +addToolBar(Qt::LeftToolBarArea,tool); + +//只允许左右停靠 +tool->setAllowedAreas(Qt::RightToolBarArea | Qt::RightToolBarArea); + +//允许浮动 +tool->setFloatable(true); + + +//设置移动,总开关,无论上面设置什么 +tool->setMovable(false); +``` + +工具栏内容的设置 + +使用`addAction`方法 + +```cpp +//设置工具栏内容 +tool->addAction("你好"); +tool->addAction(open); +//添加分割线 +tool->addSeparator(); +tool->addAction(edit); +//添加控件:按钮 +QPushButton * btn = new QPushButton("aa",this); +tool->addWidget(btn); + +``` + +### 状态栏 + +```cpp + //状态栏,只能有一个 +QStatusBar * status= new QStatusBar(this); +setStatusBar(status); + + +//放标签的控件 +QLabel * label =new QLabel("提示信息",this); +status->addWidget(label); + +QLabel * label1 =new QLabel("右侧提示信息",this); +status->addPermanentWidget(label1); + + +//铆接固件,围绕着核心固件 +QDockWidget * dock = new QDockWidget("浮动",this); +addDockWidget(Qt::LeftDockWidgetArea,dock); + + +//设置中心部件, +QTextEdit * edit1 = new QTextEdit(this); +setCentralWidget(edit1); +dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea); +``` + +只允许有一个只能用`set`,否则只能用`add` + +### 表格 + +```cpp + ui->tableWidget->setColumnCount(3); + //设置表头 + ui->tableWidget->setHorizontalHeaderLabels(QStringList()<<"姓名"<<"性别"<<"年龄"); + //设置行数 + ui->tableWidget->setRowCount(5); + + //设置正文 + QStringList nameList; + nameList<<"亚瑟"<<"张飞"<<"关羽"<<"花木兰"<<"uz"; + + //设置性别 + QList sexList; + sexList<<"f"<<"m"<<"f"<<"f"<<"f"; + ui->tableWidget->setItem(0,0,new QTableWidgetItem("亚瑟")); + for(int i=0;i<5;i++) + { + int col =0; + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i])); + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(sexList.at(i))); + ui->tableWidget->setItem(i,col++,new QTableWidgetItem(QString::number(i+18))); + } + +``` + + + +![image-20220401193159148](E:\Qt Learnning\README.assets\image-20220401193159148.png) + +效果如图 + diff --git a/SOURCE/SOURCE.pro b/SOURCE/SOURCE.pro new file mode 100644 index 0000000..8a67564 --- /dev/null +++ b/SOURCE/SOURCE.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-03-29T21:53:08 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = SOURCE +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + image/res.qrc diff --git a/SOURCE/image/C.png b/SOURCE/image/C.png new file mode 100644 index 0000000..7bdc74f Binary files /dev/null and b/SOURCE/image/C.png differ diff --git a/SOURCE/image/Office.png b/SOURCE/image/Office.png new file mode 100644 index 0000000..caec635 Binary files /dev/null and b/SOURCE/image/Office.png differ diff --git a/SOURCE/image/R.gif b/SOURCE/image/R.gif new file mode 100644 index 0000000..11eb515 Binary files /dev/null and b/SOURCE/image/R.gif differ diff --git a/SOURCE/image/cpp.png b/SOURCE/image/cpp.png new file mode 100644 index 0000000..973d118 Binary files /dev/null and b/SOURCE/image/cpp.png differ diff --git a/SOURCE/image/jie.jpg b/SOURCE/image/jie.jpg new file mode 100644 index 0000000..a572ce8 Binary files /dev/null and b/SOURCE/image/jie.jpg differ diff --git a/SOURCE/image/youtube-logo_1647079616164.png b/SOURCE/image/youtube-logo_1647079616164.png new file mode 100644 index 0000000..6531f1a Binary files /dev/null and b/SOURCE/image/youtube-logo_1647079616164.png differ diff --git a/SOURCE/main.cpp b/SOURCE/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/SOURCE/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/SOURCE/mainwindow.cpp b/SOURCE/mainwindow.cpp new file mode 100644 index 0000000..7f28353 --- /dev/null +++ b/SOURCE/mainwindow.cpp @@ -0,0 +1,20 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + +// ui->actionnew->setIcon(QIcon("G:\\Downloads\\Office.png")); + + //添加资源 + ui->actionnew->setIcon(QIcon(":/C.png")); + ui->actionOK->setIcon(QIcon(":/Office.png")); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/SOURCE/mainwindow.h b/SOURCE/mainwindow.h new file mode 100644 index 0000000..40fd472 --- /dev/null +++ b/SOURCE/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/SOURCE/mainwindow.ui b/SOURCE/mainwindow.ui new file mode 100644 index 0000000..c002a47 --- /dev/null +++ b/SOURCE/mainwindow.ui @@ -0,0 +1,113 @@ + + + MainWindow + + + + 0 + 0 + 634 + 491 + + + + MainWindow + + + + + + 10 + 10 + 501 + 451 + + + + + + + + 0 + 0 + 634 + 26 + + + + + file + + + + + + + + + + debug + + + + + + + + + + + Qt::Vertical + + + LeftToolBarArea + + + false + + + + + + Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea + + + 1 + + + + + + new + + + + + OK + + + + + open + + + + + Ok + + + + + ok + + + + + OK + + + + + + + diff --git a/datastruct/datastruct.pro b/datastruct/datastruct.pro new file mode 100644 index 0000000..181e400 --- /dev/null +++ b/datastruct/datastruct.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-03T12:06:07 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = datastruct +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + res.qrc diff --git a/datastruct/main.cpp b/datastruct/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/datastruct/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/datastruct/res.qrc b/datastruct/res.qrc new file mode 100644 index 0000000..7266a04 --- /dev/null +++ b/datastruct/res.qrc @@ -0,0 +1,5 @@ + + + res/map.png + + diff --git a/datastruct/res/map.png b/datastruct/res/map.png new file mode 100644 index 0000000..23ca833 Binary files /dev/null and b/datastruct/res/map.png differ diff --git a/datastruct/widget.cpp b/datastruct/widget.cpp new file mode 100644 index 0000000..e3dc37d --- /dev/null +++ b/datastruct/widget.cpp @@ -0,0 +1,14 @@ +#include "widget.h" +#include "ui_widget.h" + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/datastruct/widget.h b/datastruct/widget.h new file mode 100644 index 0000000..e029952 --- /dev/null +++ b/datastruct/widget.h @@ -0,0 +1,23 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/datastruct/widget.ui b/datastruct/widget.ui new file mode 100644 index 0000000..4a8f108 --- /dev/null +++ b/datastruct/widget.ui @@ -0,0 +1,20 @@ + + + Widget + + + + 0 + 0 + 870 + 607 + + + + Widget + + + + + + diff --git a/demo1/choose.cpp b/demo1/choose.cpp new file mode 100644 index 0000000..9c5b061 --- /dev/null +++ b/demo1/choose.cpp @@ -0,0 +1,97 @@ +#include "choose.h" +#include "mybutton.h" +#include +#include +#include +choose::choose(QWidget *parent) : QMainWindow(parent) +{ + //配置选择关卡大小 + setFixedSize(320,588); + setWindowIcon(QIcon(":/res/Coin0001.png")); + setWindowTitle("反转金币"); + + //创建菜单栏 + QMenuBar *bar= menuBar(); + setMenuBar(bar); + + + //创建开始菜单 + QMenu *startMenu= bar->addMenu("开始"); + + //创建退出开始项 + QAction * quit= startMenu->addAction("退出"); + + //点击退出,实现退出游戏 + connect(quit,&QAction::triggered,[=]() + { + this->close(); + }); + + //返回按钮 + mybutton *backbtn= new mybutton(":/res/BackButton.png",":/res/BackButtonSelected.png"); + backbtn->setParent(this); + backbtn->move(this->width()-backbtn->width(),this->height()-backbtn->height()); + connect(backbtn,&mybutton::clicked,[=]() + { + qDebug()<<"点击"; + //告诉主场景,我返回了 + emit this->chooseBack(); + }); + + //创建选择关卡的按钮 + + for(int i=0;i<20;i++) + { + + mybutton *menuButton = new mybutton(":/res/LevelIcon.png"); + + //监听每一按钮的点击事件 + connect(menuButton,&mybutton::clicked,[=]() + { +// QString str=; +// qDebug()<hide(); + this->show(); + }); + play->show();//显示场景 + this->hide();//隐藏当前界面 + + }); + + + menuButton->setParent(this); + menuButton->move(20+i%4*75,60+(i/4+1)*80); + + QLabel *label=new QLabel; + label->setParent(this); + label->setFixedSize(menuButton->width(),menuButton->height()); + label->setText(QString::number(i)); + label->move(20+i%4*75,60+(i/4+1)*80); + + //设置label文字对其方式 + label->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + + //设置让鼠标穿透 + label->setAttribute(Qt::WA_TransparentForMouseEvents); + } + +} + + +void choose::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QPixmap pix; + pix.load(":/res/OtherSceneBg.png"); + painter.drawPixmap(0,0,this->width(),this->height(),pix); + + + //加载标题 + pix.load(":/res/Title.png"); + painter.drawPixmap(10,30,pix.width(),pix.height(),pix); + +} diff --git a/demo1/choose.h b/demo1/choose.h new file mode 100644 index 0000000..81e2acb --- /dev/null +++ b/demo1/choose.h @@ -0,0 +1,22 @@ +#ifndef CHOOSE_H +#define CHOOSE_H + +#include "playsence.h" + +#include +#include +class choose : public QMainWindow +{ + Q_OBJECT +public: + explicit choose(QWidget *parent = nullptr); + void paintEvent(QPaintEvent *); + playsence *play; + +signals: + //写一个自定义的信号 + void chooseBack(); +public slots: +}; + +#endif // CHOOSE_H diff --git a/demo1/dataconfig.cpp b/demo1/dataconfig.cpp new file mode 100644 index 0000000..18eb5a3 --- /dev/null +++ b/demo1/dataconfig.cpp @@ -0,0 +1,378 @@ +#include "dataconfig.h" +#include +dataConfig::dataConfig(QObject *parent) : QObject(parent) +{ + + int array1[4][4] = {{1, 1, 1, 1}, + {1, 1, 0, 1}, + {1, 0, 0, 0}, + {1, 1, 0, 1} } ; + + QVector< QVector> v; + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + + v1.push_back(array1[i][j]); + } + v.push_back(v1); + } + + mData.insert(1,v); + + + int array2[4][4] = { {1, 0, 1, 1}, + {0, 0, 1, 1}, + {1, 1, 0, 0}, + {1, 1, 0, 1}} ; + + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array2[i][j]); + } + v.push_back(v1); + } + + mData.insert(2,v); + + + + int array3[4][4] = { {0, 0, 0, 0}, + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {0, 0, 0, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array3[i][j]); + } + v.push_back(v1); + } + + mData.insert(3,v); + + + int array4[4][4] = { {0, 1, 1, 1}, + {1, 0, 0, 1}, + {1, 0, 1, 1}, + {1, 1, 1, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array4[i][j]); + } + v.push_back(v1); + } + + mData.insert(4,v); + + + int array5[4][4] = { {1, 0, 0, 1}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {1, 0, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array5[i][j]); + } + v.push_back(v1); + } + + mData.insert(5,v); + + + int array6[4][4] = { {1, 0, 0, 1}, + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {1, 0, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array6[i][j]); + } + v.push_back(v1); + } + + mData.insert(6,v); + + + int array7[4][4] = { {0, 1, 1, 1}, + {1, 0, 1, 1}, + {1, 1, 0, 1}, + {1, 1, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array7[i][j]); + } + v.push_back(v1); + } + + mData.insert(7,v); + + int array8[4][4] = { {0, 1, 0, 1}, + {1, 0, 0, 0}, + {0, 0, 0, 1}, + {1, 0, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array8[i][j]); + } + v.push_back(v1); + } + + mData.insert(8,v); + + int array9[4][4] = { {1, 0, 1, 0}, + {1, 0, 1, 0}, + {0, 0, 1, 0}, + {1, 0, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array9[i][j]); + } + v.push_back(v1); + } + + mData.insert(9,v); + + + + int array10[4][4] = { {1, 0, 1, 1}, + {1, 1, 0, 0}, + {0, 0, 1, 1}, + {1, 1, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array10[i][j]); + } + v.push_back(v1); + } + + mData.insert(10,v); + + + int array11[4][4] = { {0, 1, 1, 0}, + {1, 0, 0, 1}, + {1, 0, 0, 1}, + {0, 1, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array11[i][j]); + } + v.push_back(v1); + } + + mData.insert(11,v); + + int array12[4][4] = { {0, 1, 1, 0}, + {0, 0, 0, 0}, + {1, 1, 1, 1}, + {0, 0, 0, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array12[i][j]); + } + v.push_back(v1); + } + + mData.insert(12,v); + + + int array13[4][4] = { {0, 1, 1, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 1, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array13[i][j]); + } + v.push_back(v1); + } + + mData.insert(13,v); + + int array14[4][4] = { {1, 0, 1, 1}, + {0, 1, 0, 1}, + {1, 0, 1, 0}, + {1, 1, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array14[i][j]); + } + v.push_back(v1); + } + + mData.insert(14,v); + + + int array15[4][4] = { {0, 1, 0, 1}, + {1, 0, 0, 0}, + {1, 0, 0, 0}, + {0, 1, 0, 1}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array15[i][j]); + } + v.push_back(v1); + } + + mData.insert(15,v); + + + int array16[4][4] = { {0, 1, 1, 0}, + {1, 1, 1, 1}, + {1, 1, 1, 1}, + {0, 1, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array16[i][j]); + } + v.push_back(v1); + } + + mData.insert(16,v); + + int array17[4][4] = { {0, 1, 1, 1}, + {0, 1, 0, 0}, + {0, 0, 1, 0}, + {1, 1, 1, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array17[i][j]); + } + v.push_back(v1); + } + + mData.insert(17,v); + + + int array18[4][4] = { {0, 0, 0, 1}, + {0, 0, 1, 0}, + {0, 1, 0, 0}, + {1, 0, 0, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array18[i][j]); + } + v.push_back(v1); + } + + mData.insert(18,v); + + int array19[4][4] = { {0, 1, 0, 0}, + {0, 1, 1, 0}, + {0, 0, 1, 1}, + {0, 0, 0, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array19[i][j]); + } + v.push_back(v1); + } + + mData.insert(19,v); + + int array20[4][4] = { {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}} ; + v.clear(); + for(int i = 0 ; i < 4;i++) + { + QVectorv1; + for(int j = 0 ; j < 4;j++) + { + v1.push_back(array20[i][j]); + } + v.push_back(v1); + } + + mData.insert(20,v); + + + //测试数据 +// for( QMap > >::iterator it = mData.begin();it != mData.end();it++ ) +// { +// for(QVector< QVector >::iterator it2 = (*it).begin(); it2!= (*it).end();it2++) +// { +// for(QVector::iterator it3 = (*it2).begin(); it3 != (*it2).end(); it3++ ) +// { +// qDebug() << *it3 ; +// } +// } +// qDebug() << endl; +// } + + +} diff --git a/demo1/dataconfig.h b/demo1/dataconfig.h new file mode 100644 index 0000000..b406934 --- /dev/null +++ b/demo1/dataconfig.h @@ -0,0 +1,25 @@ +#ifndef DATACONFIG_H +#define DATACONFIG_H + +#include +#include +#include + +class dataConfig : public QObject +{ + Q_OBJECT +public: + explicit dataConfig(QObject *parent = 0); + +public: + + QMap > >mData; + + + +signals: + +public slots: +}; + +#endif // DATACONFIG_H diff --git a/demo1/demo1.pro b/demo1/demo1.pro new file mode 100644 index 0000000..6ab5fda --- /dev/null +++ b/demo1/demo1.pro @@ -0,0 +1,53 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T15:09:50 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = demo1 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainsence.cpp \ + mybutton.cpp \ + choose.cpp \ + playsence.cpp \ + mycoin.cpp \ + dataconfig.cpp + +HEADERS += \ + mainsence.h \ + mybutton.h \ + choose.h \ + playsence.h \ + mycoin.h \ + dataconfig.h + +FORMS += \ + mainsence.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + res.qrc diff --git a/demo1/main.cpp b/demo1/main.cpp new file mode 100644 index 0000000..dea45ed --- /dev/null +++ b/demo1/main.cpp @@ -0,0 +1,11 @@ +#include "mainsence.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + mainsence w; + w.show(); + + return a.exec(); +} diff --git a/demo1/mainsence.cpp b/demo1/mainsence.cpp new file mode 100644 index 0000000..f808ced --- /dev/null +++ b/demo1/mainsence.cpp @@ -0,0 +1,84 @@ +#include "mainsence.h" +#include "ui_mainsence.h" +#include"mybutton.h" +#include +#include +#include + +mainsence::mainsence(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::mainsence) +{ + ui->setupUi(this); + + //配置场镜 + + //设置固定大小,图标,标题 + setFixedSize(320,588); + setWindowIcon(QIcon(":/res/Coin0001.png")); + setWindowTitle("反转金币"); + + //退出按钮 + connect(ui->actionquit,&QAction::triggered,this,[=]() + { + this->close(); + }); + + //开始按钮 + + mybutton *startbutoon = new mybutton(":/res/MenuSceneStartButton.png"); + startbutoon->setParent(this); + startbutoon->move(this->width()*0.5-startbutoon->width()*0.5,this->height()*0.7); + + connect(startbutoon,&mybutton::clicked,[=]() + { + qDebug()<<"click"; + //做一个谈起的特效 + startbutoon->zoom1(); + startbutoon->zoom2(); + + + //进入到选择关卡的场镜 + //实例化管卡 + choosesence = new choose; + connect(choosesence,&choose::chooseBack,[=]() + { + QTimer::singleShot(500,this,[=](){ + + choosesence->hide(); + this->show(); + }); + + }); + //延时进入选择关卡 + QTimer::singleShot(500,this,[=]() + { + this->hide(); + choosesence->show(); + //监听选择关卡返回按钮的信号 + }); + + }); +} +void mainsence::paintEvent(QPaintEvent *) +{ + //创建画家 + QPainter painter(this); + //创建Qpixmap对象 + QPixmap pix; + //加载图片 + pix.load(":/res/PlayLevelSceneBg.png"); + //绘制背景图,拉升成背景 + painter.drawPixmap(0,0,this->width(),this->height(),pix); + + //加载标题 + pix.load(":/res/Title.png"); + //缩放图片 + pix = pix.scaled(pix.width()*0.5,pix.height()*0.5); + //绘制标题 + painter.drawPixmap(10,30,pix.width(),pix.height(),pix); +} +mainsence::~mainsence() +{ + delete ui; +} diff --git a/demo1/mainsence.h b/demo1/mainsence.h new file mode 100644 index 0000000..20a97ae --- /dev/null +++ b/demo1/mainsence.h @@ -0,0 +1,24 @@ +#ifndef MAINSENCE_H +#define MAINSENCE_H +#include "choose.h" +#include + +namespace Ui { +class mainsence; +} + +class mainsence : public QMainWindow +{ + Q_OBJECT + +public: + explicit mainsence(QWidget *parent = nullptr); + void paintEvent(QPaintEvent *); + ~mainsence(); + choose *choosesence=NULL; + +private: + Ui::mainsence *ui; +}; + +#endif // MAINSENCE_H diff --git a/demo1/mainsence.ui b/demo1/mainsence.ui new file mode 100644 index 0000000..208234d --- /dev/null +++ b/demo1/mainsence.ui @@ -0,0 +1,43 @@ + + + mainsence + + + + 0 + 0 + 400 + 300 + + + + mainsence + + + + + + 0 + 0 + 400 + 26 + + + + + 开始 + + + + + + + + quit + + + + + + + diff --git a/demo1/mybutton.cpp b/demo1/mybutton.cpp new file mode 100644 index 0000000..ae16f8a --- /dev/null +++ b/demo1/mybutton.cpp @@ -0,0 +1,148 @@ +#include "mybutton.h" +#include +#include + +//mybutton::mybutton(QWidget *parent) : QPushButton(parent) +//{ + + +//} +mybutton::mybutton(QString normalImg,QString pressImg) +{ + this->normalImgPath=normalImg; + this->pressImg=pressImg; + + + QPixmap pix; + bool ret=pix.load(normalImg); + if(!ret) + { + qDebug()<<"fail"; + return; + } + + //设置图片固定大小 + this->setFixedSize(pix.width(),pix.height()); + + //设置不规则图片样式 + this->setStyleSheet("QPushButton{border:0px;}"); + + + //设置图标 + this->setIcon(pix); + + //设置图标的大小 + this->setIconSize(QSize(pix.width(),pix.height())); + +} +void mybutton::zoom1() +{ + //创建动画对象 + QPropertyAnimation * animation =new QPropertyAnimation(this,"geometry"); + + //创建时间间隔 + + animation->setDuration(200); + + //创建起始位置 + + animation->setStartValue(QRect(this->x(),this->y(),this->width(),this->height())); + + //创建结束位置 + animation->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height())); + + + + //设置缓和曲线 + animation->setEasingCurve(QEasingCurve::OutBounce); + + //开始执行动画 + animation->start(); + + +} + +void mybutton::zoom2() +{ + //创建动画对象 + QPropertyAnimation * animation =new QPropertyAnimation(this,"geometry"); + + //创建时间间隔 + + animation->setDuration(200); + + //创建起始位置 + + animation->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height())); + + //创建结束位置 + animation->setEndValue(QRect(this->x(),this->y(),this->width(),this->height())); + + + + //设置缓和曲线 + animation->setEasingCurve(QEasingCurve::OutBounce); + + //开始执行动画 + animation->start(); + +} + +void mybutton:: mousePressEvent(QMouseEvent *e) +{ + if(pressImg!=NULL) + { + QPixmap pix; + bool ret=pix.load(this->pressImg); + if(!ret) + { + qDebug()<<"fail"; + return; + } + + //设置图片固定大小 + this->setFixedSize(pix.width(),pix.height()); + + //设置不规则图片样式 + this->setStyleSheet("QPushButton{border:0px;}"); + + + //设置图标 + this->setIcon(pix); + + //设置图标的大小 + this->setIconSize(QSize(pix.width(),pix.height())); + + } + //让父类执行下面操作 + return QPushButton::mousePressEvent(e); +} + + +void mybutton:: mouseReleaseEvent(QMouseEvent *e) +{ + if(pressImg!=NULL) + { + QPixmap pix; + bool ret=pix.load(this->normalImgPath); + if(!ret) + { + qDebug()<<"fail"; + return; + } + + //设置图片固定大小 + this->setFixedSize(pix.width(),pix.height()); + + //设置不规则图片样式 + this->setStyleSheet("QPushButton{border:0px;}"); + + + //设置图标 + this->setIcon(pix); + + //设置图标的大小 + this->setIconSize(QSize(pix.width(),pix.height())); + } + return QPushButton::mouseReleaseEvent(e); +} diff --git a/demo1/mybutton.h b/demo1/mybutton.h new file mode 100644 index 0000000..7b1ea35 --- /dev/null +++ b/demo1/mybutton.h @@ -0,0 +1,31 @@ +#ifndef MYBUTTON_H +#define MYBUTTON_H + +#include + +class mybutton : public QPushButton +{ + Q_OBJECT +public: + explicit mybutton(QWidget *parent = nullptr); + mybutton(QString normalImg,QString pressImg=""); + //正常显示图片的路径 + + //成员属性, + QString normalImgPath; + QString pressImg; + void zoom1(); + void zoom2(); + + //重写一下按钮的按下和释放 + void mousePressEvent(QMouseEvent *e); + + + void mouseReleaseEvent(QMouseEvent *e); + +signals: + +public slots: +}; + +#endif // MYBUTTON_H diff --git a/demo1/mycoin.cpp b/demo1/mycoin.cpp new file mode 100644 index 0000000..9d37724 --- /dev/null +++ b/demo1/mycoin.cpp @@ -0,0 +1,102 @@ +#include "mycoin.h" +#include + +mycoin::mycoin(QString buting) +{ + QPixmap pix; + bool ret = pix.load(buting); + if(!ret) + { + qDebug()<<"加载失败"; + } + this->isannimation=false; + + this->setFixedSize(pix.width(),pix.height()); + this->setStyleSheet("QPushButton{border:0px}"); + this->setIcon(pix); + this->setIconSize(QSize(pix.width(),pix.height())); + + //初始化一下定时器对象 + timer1 = new QTimer(this); + timer2 = new QTimer(this); + + //监听正面翻翻面的信号 + min=1;max=8; + connect(timer1,&QTimer::timeout,[=]() + { + QPixmap pix; + QString str = QString(":/res/Coin000%1.png").arg(this->min++); + pix.load(str); + + this->setFixedSize(pix.width(),pix.height()); + this->setStyleSheet("QPushButton{border:0px}"); + this->setIcon(pix); + this->setIconSize(QSize(pix.width(),pix.height())); + //如果翻完了,让min为1 + if(this->min>this->max) + { + this->min=1; + timer1->stop(); + this->isannimation =false; + } + }); + +// 反面翻正面 + connect(timer2,&QTimer::timeout,[=]() + { + QPixmap pix; + //this->max=8; + //this->min=1; + QString str = QString(":/res/Coin000%1.png").arg(this->max--); + pix.load(str); + + this->setFixedSize(pix.width(),pix.height()); + this->setStyleSheet("QPushButton{border:0px}"); + this->setIcon(pix); + this->setIconSize(QSize(pix.width(),pix.height())); + //如果翻完了,让max为8 + if(this->maxmin) + { + this->max=8; + timer2->stop(); + this->isannimation =false; + } + }); +} + + +//改变正反面的标志 +void mycoin::changeflag() +{ + //如果是正面,翻成反面 + if(this->flag) + { + + //开始正面翻方面 + timer1->start(30); + isannimation =true; + this->flag=false; + qDebug()<posx<<" "<posx<<" "<start(30); + isannimation =true; + this->flag=true; + } + +} +//重写按下的转台 +void mycoin::mousePressEvent(QMouseEvent *e) +{ + + if(this->isannimation==true) + { + return; + } + else { + QPushButton::mousePressEvent(e); + } +} diff --git a/demo1/mycoin.h b/demo1/mycoin.h new file mode 100644 index 0000000..fb6573c --- /dev/null +++ b/demo1/mycoin.h @@ -0,0 +1,41 @@ +#ifndef MYCOIN_H +#define MYCOIN_H +#include +#include +#include + +class mycoin : public QPushButton +{ + Q_OBJECT +public: + + //传入显示的图片 + mycoin(QString buting); + + + //金币的属性 + int posx; + int posy; + bool flag;//正反的标志 + int min; + int max; + + //改变标志的方法 + void changeflag(); + QTimer *timer1; + QTimer *timer2; + + //执行动画 + bool isannimation; + + + //重写按下状态 + void mousePressEvent(QMouseEvent *e); + + +signals: + +public slots: +}; + +#endif // MYCOIN_H diff --git a/demo1/playsence.cpp b/demo1/playsence.cpp new file mode 100644 index 0000000..d608c78 --- /dev/null +++ b/demo1/playsence.cpp @@ -0,0 +1,202 @@ +#include "mybutton.h" +#include "mycoin.h" +#include "playsence.h" +#include +#include +#include +#include +#include +#include"dataconfig.h" +#include +playsence::playsence(int number) +{ + this->levelindex = number; + qDebug()<levelindex); + + //初始化固定大小 + + this->setFixedSize(320,588); + + //设置图标 + this->setWindowIcon(QPixmap(":/res/Coin0001.png")); + + //设置标题 + this->setWindowTitle("翻金币"); + + + //创建菜单栏 + QMenuBar *bar= menuBar(); + setMenuBar(bar); + + + //创建开始菜单 + QMenu *startMenu= bar->addMenu("开始"); + + //创建退出开始项 + QAction * quit= startMenu->addAction("退出"); + + //点击退出,实现退出游戏 + connect(quit,&QAction::triggered,[=]() + { + this->close(); + }); + + + mybutton *back= new mybutton(QString(":/res/BackButton.png"), + QString(":/res/BackButtonSelected.png")); + + back->setParent(this); + //移动位置 + back->move(this->width()-back->width(),this->height()-back->height()); + + connect(back,&mybutton::clicked,[=]() + { + emit this->backtolastleve(); + this->hide(); + qDebug()<<"来了"; + }); + + + //设置关卡数 + QLabel *label = new QLabel; + label->setParent(this); + + QFont font; + font.setFamily("华文新魏"); + font.setPointSize(20); + //将字体设置到标签控件 + label->setFont(font); + + QString str2= QString ("Level%1").arg(this->levelindex); + label->setText(str2); + label->setGeometry(30,this->height()-50,120,50); + + dataConfig config; + for(int i=0;i<4;i++) + { + for(int j=0;j<4;j++) + { + this->gameArray[i][j]=config.mData[this->levelindex][i][j]; + } + } + + //设置胜利图片 + QLabel *winlabel = new QLabel; + winlabel->setParent(this); + QPixmap tempix; + tempix.load(":/res/LevelCompletedDialogBg.png"); + winlabel->setGeometry(0,0,tempix.width(),tempix.height()); + winlabel->setPixmap(tempix); + winlabel->move((this->width()-tempix.width())*0.5,-tempix.height()); + connect(this,&playsence::victory,[=]() + { + qDebug()<<"完成"; + + QPropertyAnimation *animation = new QPropertyAnimation(winlabel,"geometry"); + //设值时间间隔 + animation->setDuration(1000); + //设置开始位置 + + animation->setStartValue(QRect(winlabel->x(),winlabel->y(),winlabel->width(),winlabel->height())); + //设置结束位置 + animation->setEndValue(QRect(winlabel->x(),winlabel->y()+114,winlabel->width(),winlabel->height())); + //设置缓和曲线 + animation->setEasingCurve(QEasingCurve::OutBounce); + animation->start(); + }); + + + + //显示金币的背景图 + for(int i=0;i<4;i++) + { + for(int j=0;j<4;j++) + { + QLabel *label = new QLabel; + label->setGeometry(0,0,50,50); + label->setPixmap(QPixmap(":/res/BoardNode(1).png")); + label->setParent(this); + label->move(57+i*50,200+j*50); + + //显示金币 + mycoin * coin; + + if(this->gameArray[i][j]==1) + coin = new mycoin(":/res/Coin0001.png"); + else + coin = new mycoin(":/res/Coin0008.png"); + + coin->setParent(this); + coin->move(59+i*50,204+j*50); + + //给金币属性赋值 + coin->posx =i; + coin->posy =j; + coin->flag = gameArray[i][j]; //一表示正面,0表示发面 + + this->coinList[i][j]=coin; + //点击金币,进行反正 + connect(coin,&mycoin::clicked,[=]() + { + coin->changeflag(); + this->gameArray[i][j]=this->gameArray[i][j]==0?1:0; + QTimer::singleShot(300,this,[=](){ + if(coin->posx+1<4) + { + this->coinList[coin->posx+1][coin->posy]->changeflag(); + this->gameArray[coin->posx+1][coin->posy]==this->gameArray[coin->posx+1][coin->posy]==0?1:0; + } + if(coin->posx-1>=0) + { + this->coinList[coin->posx-1][coin->posy]->changeflag(); + this->gameArray[coin->posx-1][coin->posy]==this->gameArray[coin->posx-1][coin->posy]==0?1:0; + } + if(coin->posy+1<4) + { + this->coinList[coin->posx][coin->posy+1]->changeflag(); + this->gameArray[coin->posx][coin->posx+1]==this->gameArray[coin->posx][coin->posy+1]==0?1:0; + } + if(coin->posy-1>=0) + { + this->coinList[coin->posx][coin->posy-1]->changeflag(); + this->gameArray[coin->posx][coin->posx-1]==this->gameArray[coin->posx][coin->posy-1]==0?1:0; + } + this->vic=1; + for(int i =0;i<4;i++){ + for(int j=0;j<4;j++) + { + vic=vic&&gameArray[i][j]; + qDebug()<victory(); + } + + }); + + }); + + } + } + + + + +} + +void playsence::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QPixmap pix; + pix.load(":/res/PlayLevelSceneBg.png"); + painter.drawPixmap(0,0,this->width(),this->height(),pix); + + + //加载标题 + pix.load(":/res/Title.png"); + pix = pix.scaled(pix.width()*0.5 ,pix.height()*0.5); + painter.drawPixmap(10,30,pix.width(),pix.height(),pix); +} diff --git a/demo1/playsence.h b/demo1/playsence.h new file mode 100644 index 0000000..7f230eb --- /dev/null +++ b/demo1/playsence.h @@ -0,0 +1,29 @@ +#ifndef PLAYSENCE_H +#define PLAYSENCE_H + +#include "mycoin.h" + +#include + +class playsence : public QMainWindow +{ + Q_OBJECT +public: + playsence(int number); + int levelindex; + + //重写paintevent事件 + void paintEvent(QPaintEvent *); + int gameArray[4][4]; + mycoin * coinList[4][4]; + + + //是否胜利 + int vic; +signals: + void backtolastleve(); + void victory(); +public slots: +}; + +#endif // PLAYSENCE_H diff --git a/demo1/res.qrc b/demo1/res.qrc new file mode 100644 index 0000000..bda86f2 --- /dev/null +++ b/demo1/res.qrc @@ -0,0 +1,31 @@ + + + res/Coin0001.png + res/Coin0002.png + res/Coin0003.png + res/Coin0004.png + res/Coin0005.png + res/Coin0006.png + res/Coin0007.png + res/Coin0008.png + res/ConFlipSound.wav + res/LevelCompletedDialogBg.png + res/LevelIcon.png + res/LevelWinSound.wav + res/mainBg.png + res/mainBg1.png + res/MenuSceneBg.png + res/MenuSceneStartButton.png + res/OtherSceneBg.png + res/PlayLevelSceneBg.png + res/TapButtonSound.wav + res/Title.png + res/window.png + res/winGain.mp3 + res/BackButton.png + res/BackButtonSelected.png + res/BackButtonSound.wav + res/bkmusic.mp3 + res/BoardNode(1).png + + diff --git a/demo1/res/BackButton.png b/demo1/res/BackButton.png new file mode 100644 index 0000000..cf72db0 Binary files /dev/null and b/demo1/res/BackButton.png differ diff --git a/demo1/res/BackButtonSelected.png b/demo1/res/BackButtonSelected.png new file mode 100644 index 0000000..843be2d Binary files /dev/null and b/demo1/res/BackButtonSelected.png differ diff --git a/demo1/res/BackButtonSound.wav b/demo1/res/BackButtonSound.wav new file mode 100644 index 0000000..5d6dabc Binary files /dev/null and b/demo1/res/BackButtonSound.wav differ diff --git a/demo1/res/BoardNode(1).png b/demo1/res/BoardNode(1).png new file mode 100644 index 0000000..2029f83 Binary files /dev/null and b/demo1/res/BoardNode(1).png differ diff --git a/demo1/res/Coin0001.png b/demo1/res/Coin0001.png new file mode 100644 index 0000000..8db4cc3 Binary files /dev/null and b/demo1/res/Coin0001.png differ diff --git a/demo1/res/Coin0002.png b/demo1/res/Coin0002.png new file mode 100644 index 0000000..cfc0fd7 Binary files /dev/null and b/demo1/res/Coin0002.png differ diff --git a/demo1/res/Coin0003.png b/demo1/res/Coin0003.png new file mode 100644 index 0000000..a3d67ab Binary files /dev/null and b/demo1/res/Coin0003.png differ diff --git a/demo1/res/Coin0004.png b/demo1/res/Coin0004.png new file mode 100644 index 0000000..1d50aab Binary files /dev/null and b/demo1/res/Coin0004.png differ diff --git a/demo1/res/Coin0005.png b/demo1/res/Coin0005.png new file mode 100644 index 0000000..4d72e86 Binary files /dev/null and b/demo1/res/Coin0005.png differ diff --git a/demo1/res/Coin0006.png b/demo1/res/Coin0006.png new file mode 100644 index 0000000..772a3e1 Binary files /dev/null and b/demo1/res/Coin0006.png differ diff --git a/demo1/res/Coin0007.png b/demo1/res/Coin0007.png new file mode 100644 index 0000000..00401b9 Binary files /dev/null and b/demo1/res/Coin0007.png differ diff --git a/demo1/res/Coin0008.png b/demo1/res/Coin0008.png new file mode 100644 index 0000000..8055b44 Binary files /dev/null and b/demo1/res/Coin0008.png differ diff --git a/demo1/res/ConFlipSound.wav b/demo1/res/ConFlipSound.wav new file mode 100644 index 0000000..4e6eed6 Binary files /dev/null and b/demo1/res/ConFlipSound.wav differ diff --git a/demo1/res/LevelCompletedDialogBg.png b/demo1/res/LevelCompletedDialogBg.png new file mode 100644 index 0000000..96921e5 Binary files /dev/null and b/demo1/res/LevelCompletedDialogBg.png differ diff --git a/demo1/res/LevelIcon.png b/demo1/res/LevelIcon.png new file mode 100644 index 0000000..80e0fa8 Binary files /dev/null and b/demo1/res/LevelIcon.png differ diff --git a/demo1/res/LevelWinSound.wav b/demo1/res/LevelWinSound.wav new file mode 100644 index 0000000..d94fd09 Binary files /dev/null and b/demo1/res/LevelWinSound.wav differ diff --git a/demo1/res/MenuSceneBg.png b/demo1/res/MenuSceneBg.png new file mode 100644 index 0000000..54bd736 Binary files /dev/null and b/demo1/res/MenuSceneBg.png differ diff --git a/demo1/res/MenuSceneStartButton.png b/demo1/res/MenuSceneStartButton.png new file mode 100644 index 0000000..8027fc9 Binary files /dev/null and b/demo1/res/MenuSceneStartButton.png differ diff --git a/demo1/res/OtherSceneBg.png b/demo1/res/OtherSceneBg.png new file mode 100644 index 0000000..ab8f18b Binary files /dev/null and b/demo1/res/OtherSceneBg.png differ diff --git a/demo1/res/PlayLevelSceneBg.png b/demo1/res/PlayLevelSceneBg.png new file mode 100644 index 0000000..eb88af0 Binary files /dev/null and b/demo1/res/PlayLevelSceneBg.png differ diff --git a/demo1/res/TapButtonSound.wav b/demo1/res/TapButtonSound.wav new file mode 100644 index 0000000..a514d04 Binary files /dev/null and b/demo1/res/TapButtonSound.wav differ diff --git a/demo1/res/Title.png b/demo1/res/Title.png new file mode 100644 index 0000000..386ebf8 Binary files /dev/null and b/demo1/res/Title.png differ diff --git a/demo1/res/bkmusic.mp3 b/demo1/res/bkmusic.mp3 new file mode 100644 index 0000000..717c9bc Binary files /dev/null and b/demo1/res/bkmusic.mp3 differ diff --git a/demo1/res/mainBg.png b/demo1/res/mainBg.png new file mode 100644 index 0000000..6e05e22 Binary files /dev/null and b/demo1/res/mainBg.png differ diff --git a/demo1/res/mainBg1.png b/demo1/res/mainBg1.png new file mode 100644 index 0000000..5ab9de2 Binary files /dev/null and b/demo1/res/mainBg1.png differ diff --git a/demo1/res/winGain.mp3 b/demo1/res/winGain.mp3 new file mode 100644 index 0000000..76e59e5 Binary files /dev/null and b/demo1/res/winGain.mp3 differ diff --git a/demo1/res/window.png b/demo1/res/window.png new file mode 100644 index 0000000..7c21392 Binary files /dev/null and b/demo1/res/window.png differ diff --git a/dta.7z b/dta.7z new file mode 100644 index 0000000..51d7f1e Binary files /dev/null and b/dta.7z differ diff --git a/dta/dta.pro b/dta/dta.pro new file mode 100644 index 0000000..63c7b2b --- /dev/null +++ b/dta/dta.pro @@ -0,0 +1,55 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-03T12:12:22 +# +#------------------------------------------------- + +QT += core gui +QT += multimedia +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = dta +TEMPLATE = app +RC_ICONS = logo.ico +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +CONFIG+=resources_big + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + mylabel.cpp \ + mybtn.cpp \ + mytext.cpp \ + mysound.cpp \ + mysounds.cpp + +HEADERS += \ + mainwindow.h \ + mylabel.h \ + mybtn.h \ + mytext.h \ + mysound.h \ + mysounds.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + res.qrc diff --git a/dta/logo.ico b/dta/logo.ico new file mode 100644 index 0000000..0e7ec63 Binary files /dev/null and b/dta/logo.ico differ diff --git a/dta/main.cpp b/dta/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/dta/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/dta/mainwindow.cpp b/dta/mainwindow.cpp new file mode 100644 index 0000000..e3100c4 --- /dev/null +++ b/dta/mainwindow.cpp @@ -0,0 +1,523 @@ +#include "mainwindow.h" +#include "mytext.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include + + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + + + //设置go按键 + + + + dot= new QStringList; + + this->setWindowFlags(this->windowFlags()&~Qt::WindowMinMaxButtonsHint); + this->x1=1; + this->x2=0; + this->y1=0; + this->y2=0; + this->lastqi=-1; + this->lastzong=-1; + //新开进程 + //设置logo + setWindowIcon(QIcon(":/res/logo.ico")); + + + //设置燕大图标 + + this->setpic(); + + ui->setupUi(this); + setFixedSize(1250,740); + + //定义一个ptr的数组,来装我的label + ptr= new mylabel*[MAXSIZE]; + + //先将距离矩阵配置为正无穷 + this->setmaxtrix(); + + //初始化最短路径列表为-1 + InitRoute(); + + this->go=new mybtn(); +// this->go->setText("开始导航"); + go->setParent(this); + // this->go->setGeometry(1086,600,120,100); + go->pox=1160; + go->poy=670; + go->moveto(); + go->show(); + + //读取label(point) + loaddata(); + + //定义起点框和终点框 + select(); + + //定义文本框 + this->Tex= new MyText(); + this->Tex->setParent(this); + this->Tex->setGeometry(1100,140,125,400); + + //设置动画等 + graph(); + + + //语音 + //mysound sound(); + //地点的点击 + + +// sound= new mysounds(this); + //点击go + + connect(go,&mybtn::clicked,this,[&]() + { + for(int i=0;itag=0; + } + + go->knowb(); + +// qDebug()<currentIndex(); + Dijkstra(qidian->currentIndex()); + QString Line = luxian[zongdian->currentIndex()]; + +// qDebug()<tag=1; + } + }); + + + +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +//定义起点框和终点框 +void MainWindow::select() +{ + //定义终点及其配置 + this->qidian=new QComboBox(this); + this->qidian->setSizeAdjustPolicy(QComboBox::AdjustToContents); + QStringList q; + for(int i=0;iname; + } + this->qidian->addItems(q); + this->qidian->move(1100,32); + + //定义终点及其配置 + this->zongdian=new QComboBox(this); + this->zongdian->setSizeAdjustPolicy(QComboBox::AdjustToContents); + this->zongdian->addItems(q); + this->zongdian->move(1100,100); +} + + + +//载入数据 +void MainWindow::loaddata() +{ + //载入点 + QFile file(":/res/Point.csv"); + file.open(QIODevice::ReadOnly); + QStringList list; + QTextStream in(&file); + in.setCodec("UTF-8"); + // qDebug()<setParent(this); + q->id=list.at(0).toInt();q->name=list.at(1); + q->huan=list.at(5).toInt()-list.at(4).toInt(); //设置宽和高 + q->gao=list.at(7).toInt()-list.at(6).toInt(); + q->moveto(list.at(2).toInt(),list.at(3).toInt()); + q->x=list.at(2).toInt(); + q->y=list.at(3).toInt(); + + //设置信号与槽函数 + connect(q,&mylabel::startp,this,&MainWindow::setStartp); + connect(q,&mylabel::endp,this,&MainWindow::setEndp); + + +// connect() + + ptr[index] =q; + // qDebug() << list.at(2); + index++; + // qDebug()<<"I am ok"; + } + + file.close(); + + + + //载入距离矩阵 + QFile file1(":/res/dis.csv"); + file1.open(QIODevice::ReadOnly); + // QStringList list; + QTextStream in1(&file1); + in1.setCodec("UTF-8"); + // int index =0; + for(int i = 0;!in1.atEnd(); i++) + { + QString fileLine = in1.readLine(); + list = fileLine.split(",", QString::SkipEmptyParts); + //设置距离矩阵中的正常值 + this->distance[list.at(0).toInt()-1][list.at(1).toInt()-1]=list.at(2).toInt(); + this->distance[list.at(1).toInt()-1][list.at(0).toInt()-1]=list.at(2).toInt(); + //qDebug()<distance[list.at(0).toInt()-1][list.at(1).toInt()-1]; + } +} + +void MainWindow::setpic() +{ + ysu = new QLabel; + ysu->setParent(this); + QPixmap *pixmap = new QPixmap(QString(":/res/ysu.png")); + ysu->resize(400,200); + ysu->move(600,-30);//居中显示 + QPixmap pixmap1=pixmap->scaled(ysu->width(),ysu->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + ysu->setPixmap(pixmap1); +} + +void MainWindow::graph() +{ + //设置导航框 + QLabel *winlabel = new QLabel; + winlabel->setParent(this); + //设置鼠标穿透 + winlabel->setAttribute(Qt::WA_TransparentForMouseEvents,true); + QPixmap tempix; + tempix.load(":/qita/res/qita/daohang.png"); + winlabel->setGeometry(0,0,tempix.width(),tempix.height()); + + tempix=tempix.scaled(500,177, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + winlabel->setPixmap(tempix); + + winlabel->move((this->width()-tempix.width())*0.5,-tempix.height()); + winlabel->move(350,-300); + QGraphicsOpacityEffect *m_pGraphicsOpacityEffect = new QGraphicsOpacityEffect(winlabel); + m_pGraphicsOpacityEffect->setOpacity(0); + for(int i=0;isetDuration(2500); + //设置开始位置 + + animation->setStartValue(QRect(350,-200,winlabel->width(),winlabel->height())); + //设置结束位置 + animation->setEndValue(QRect(350,-30,winlabel->width(),winlabel->height())); + + //设置缓和曲线 + // QGraphicsOpacityEffect *m_pGraphicsOpacityEffect = new QGraphicsOpacityEffect(winlabel); + // m_pGraphicsOpacityEffect->setOpacity(1); + winlabel->setGraphicsEffect(m_pGraphicsOpacityEffect); + + + QPropertyAnimation * m_pNameAnimation = new QPropertyAnimation(m_pGraphicsOpacityEffect,"opacity",winlabel); + + + m_pNameAnimation->setStartValue(1); + m_pNameAnimation->setEasingCurve(QEasingCurve::Linear); + m_pNameAnimation->setEndValue(0); + m_pNameAnimation->setDuration(5000); + animation->setEasingCurve(QEasingCurve::OutBounce); + + m_pNameAnimation->start(); + animation->start(); + }); + + } + connect(go,&mybtn::toomany,[=]() + { + QPropertyAnimation *animation = new QPropertyAnimation(winlabel,"geometry"); + //设值时间间隔 + animation->setDuration(2500); + //设置开始位置 + + animation->setStartValue(QRect(350,-200,winlabel->width(),winlabel->height())); + //设置结束位置 + animation->setEndValue(QRect(350,-30,winlabel->width(),winlabel->height())); + + //设置缓和曲线 +// QGraphicsOpacityEffect *m_pGraphicsOpacityEffect = new QGraphicsOpacityEffect(winlabel); +// m_pGraphicsOpacityEffect->setOpacity(1); + winlabel->setGraphicsEffect(m_pGraphicsOpacityEffect); + + + QPropertyAnimation * m_pNameAnimation = new QPropertyAnimation(m_pGraphicsOpacityEffect,"opacity",winlabel); + + + m_pNameAnimation->setStartValue(1); + m_pNameAnimation->setEasingCurve(QEasingCurve::Linear); + m_pNameAnimation->setEndValue(0); + m_pNameAnimation->setDuration(5000); + animation->setEasingCurve(QEasingCurve::OutBounce); + + m_pNameAnimation->start(); + animation->start(); + +// QEventLoop loop;//定义一个新的事件循环 +// QTimer::singleShot(2500, &loop, SLOT(quit()));//创建单次定时器,槽函数为事件循环的退出函数 +// loop.exec();//事件循环开始执行,程序会卡在这里,直到定时时间到,本循环被退出 + +// m_pNameAnimation->setStartValue(1); +// m_pNameAnimation->setDuration(2500); +// m_pNameAnimation->setEasingCurve(QEasingCurve::OutBounce); +// m_pNameAnimation->setEndValue(0); + +// m_pNameAnimation->start(); + + //把所有按键禁用 + + + }); + this->setWindowTitle("ysu navigation by ninglang and his friends"); +} + + + + +//配置距离矩阵初始化 +void MainWindow::setmaxtrix() +{ + for(int i=0;idistance[i][j]=10000; + } + else + { + this->distance[i][j]=0; + } + + } + } +} + + + +//设置路线显示 +void MainWindow::settext() +{ + QString tex="路线:\n"+ptr[list.at(0).toInt()-1]->name; + for(int i=1;iname; + } + // qDebug()<changdu; + tex=tex+"\n\n"+"总长度:"+QString::number(this->changdu); + this->Tex->setText(tex); +} + + + +//设置左键输入起点,返回显示 +void MainWindow::setStartp(int i) +{ + this->qidian->setCurrentIndex(i-1); + if(lastzong!=-1&& lastzong!=i-1) + { + + this->ptr[lastzong]->status=1; + list.clear(); + update(); + this->ptr[lastzong]->setbackcolor(this->ptr[lastzong]->status); + } + + lastzong=i-1; +} + +//设置右键输入终点,返回至显示 +void MainWindow::setEndp(int i) +{ + this->zongdian->setCurrentIndex(i-1); + if(lastqi!=-1&&lastqi!=i-1) + { + + this->ptr[lastqi]->status=1; + list.clear(); + update(); + this->ptr[lastqi]->setbackcolor(this->ptr[lastqi]->status); + } + + lastqi=i-1; +} + + +//初始化Route为-1 +void MainWindow::InitRoute() +{ + for(int i=0;iroute[i]=this->distance[v][i]; + if(route[i]!=10000) + { + luxian[i]=QString("%1").arg(v+1)+QString(",")+QString("%1").arg(i+1); + dis[i]=distance[v][i]; + } + else { + luxian[i]=QString(""); + } + } + for(int num=1;numroute[i]route[cout]+distance[cout][i] && i!=v) + { + route[i]=route[cout]+distance[cout][i]; + luxian[i]=luxian[cout]+QString(",")+QString("%1").arg(i+1); + dis[i]=dis[i]+distance[cout][i]; + } + } + route[cout]=0; + + + } + + +} + + + +void MainWindow::paintEvent(QPaintEvent *) +{ + //创建画家 + QPainter painter(this); + //创建Qpixmap对象 + QPixmap pix; + pix.load(":/res/map.png"); + //绘制背景图 + painter.drawPixmap(0,0,pix.width(),pix.height(),pix); + + QPen pen; + pen.setStyle(Qt::DashLine); + pen.setColor(Qt::red); // 设置画笔为黄色 + pen.setWidth(5); + painter.setPen(pen); // 设置画笔 + if(!list.isEmpty()) + { + this->changdu=0; + for(int i =0;ilist.length()-1;i++) + { + int x1=list.at(i).toInt()-1;//点 + int x2=list.at(i+1).toInt()-1; + painter.drawLine(ptr[x1]->x,ptr[x1]->y,ptr[x2]->x,ptr[x2]->y); + + this->changdu+=distance[x1][x2]; + //qDebug()<settext(); + + } + + +} + + +//void MainWindow::paint() +//{ +// if(!dot->isEmpty()) +// { +// dot->clear(); +// } +// for(int i =0;ilist.length();i++) +// { +// int x1=list.at(i).toInt()-1;//点 +// int x=ptr[x1]->x; +// int y=ptr[x1]->y; + +// QString xy=QString("%1,%2").arg(x).arg(y); +// this->dot->append(xy); + +//// this->update(); +//// this->changdu=this->changdu+distance[x1][x2]; +// } +// qDebug()<<*dot; +//// update(); + +//} +void MainWindow::Delay_MSec(unsigned int msec) +{ + QEventLoop loop;//定义一个新的事件循环 + QTimer::singleShot(msec, &loop, SLOT(quit()));//创建单次定时器,槽函数为事件循环的退出函数 + loop.exec();//事件循环开始执行,程序会卡在这里,直到定时时间到,本循环被退出 +} + + + diff --git a/dta/mainwindow.h b/dta/mainwindow.h new file mode 100644 index 0000000..58c91ab --- /dev/null +++ b/dta/mainwindow.h @@ -0,0 +1,106 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "mybtn.h" +#include "mylabel.h" +#include "mysound.h" +#include "mysounds.h" +#include "mytext.h" +#include +#include +#include +#include +#include //音效头文件 +#define MAXSIZE 22 +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + void paintEvent(QPaintEvent *); + ~MainWindow(); + void select(); + void loaddata(); + + + //声音 +// mysounds *sound; + //定义路线 + QString luxian[MAXSIZE]; + + + //设置燕大logo + QLabel *ysu; + void setpic(); + + //设置表面背景和动画 + void graph(); + + //语音类 +// mysounds sound; + + //配置距离矩阵初始化 + void setmaxtrix(); + + QStringList *dot; + + //void paint(); + int x1,x2,y1,y2; + //画笔测试集合文件 + // int a[4][2]; + + //last点击 + int lastqi,lastzong; + + void Delay_MSec(unsigned int msec); + + //设置一个22的长度线段 + int route[MAXSIZE]; + + //定义距离矩阵 + int distance[MAXSIZE][MAXSIZE]; + + + mylabel * p; + QComboBox *qidian=NULL; + QComboBox *zongdian=NULL; + mylabel **ptr=NULL; + + //显示路线 + void settext(); + + + //最终路线 + QStringList list; + + //设置点击的起始点和终点 + void setStartp(int i); + void setEndp(int i); + + //初始化Route为-1 + void InitRoute(); + + //Dijkstra算法 + void Dijkstra(int v); + + //设置文本框 + MyText * Tex=NULL; + + //运行按钮 + mybtn * go=NULL; + + //总长度 + int changdu; + + + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/dta/mainwindow.ui b/dta/mainwindow.ui new file mode 100644 index 0000000..7adadda --- /dev/null +++ b/dta/mainwindow.ui @@ -0,0 +1,21 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + diff --git a/dta/mybtn.cpp b/dta/mybtn.cpp new file mode 100644 index 0000000..20348a7 --- /dev/null +++ b/dta/mybtn.cpp @@ -0,0 +1,114 @@ +#include "mybtn.h" + +mybtn::mybtn(QPushButton *parent) : QPushButton(parent) +{ + timer1=new QTimer(this); + timer2=new QTimer(this); + this->pox=this->x(); + this->poy=this->y(); + + + //默认可以发消息 + tag=1; + this->min=1; + this->max=4; + QPixmap pixmap; + QString str= QString(":/qita/res/qita/start1.png"); + pixmap.load(str); + pixmap=pixmap.scaled(150,70, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + this->setFixedSize(pixmap.width(),pixmap.height()); + this->setStyleSheet("QPushButton{border:0px;}"); + + this->setIcon(pixmap); + this->setIconSize(QSize(pixmap.width(),pixmap.height())); + this->move(this->pox-this->width()*0.5,this->poy-this->height()*0.5); + this->changeflag(); + +} + +void mybtn::mousePressEvent(QMouseEvent *e) +{ + //qDebug()<<"s"<start(20); +/* emit this->toomany()*/; +// qDebug()<toomany(); + timer1->start(20); +// qDebug()<start(20); +} + +void mybtn::changeflag() +{ + +// timer1->start(50); + connect(timer1,&QTimer::timeout,[=]() + { + QPixmap pixmap; + + QString str= QString(":/qita/res/qita/start%1.png").arg(this->min++); + pixmap.load(str); + pixmap=pixmap.scaled(pixmap.width()*0.39,pixmap.height()*0.39, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + this->setFixedSize(pixmap.width(),pixmap.height()); + this->setStyleSheet("QPushButton{border:0px;}"); + this->setIcon(pixmap); + this->move(pox-this->width()*0.5,poy-this->height()*0.5); + + if(min>4) + { + this->min=1; + timer1->stop(); + } + }); + +// timer1->start(50); + connect(timer2,&QTimer::timeout,[=]() + { + QPixmap pixmap; + QString str= QString(":/qita/res/qita/start%1.png").arg(this->max--); + pixmap.load(str); + pixmap=pixmap.scaled(pixmap.width()*0.39,pixmap.height()*0.39, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + this->setFixedSize(pixmap.width(),pixmap.height()); + this->setStyleSheet("QPushButton{border:0px;}"); + this->setIcon(pixmap); + this->move(pox-this->width()*0.5,poy-this->height()*0.5); + if(max<1) + { + this->max=4; + timer2->stop(); + } + }); + +} + +void mybtn::knowb() +{ + if(tag==1) + { + tag=0; + } + else { + tag=1; + emit this->ok(); + } + +} + +void mybtn::moveto() +{ + this->move(this->pox-0.5*this->width(),this->poy-0.5*this->height()); +} diff --git a/dta/mybtn.h b/dta/mybtn.h new file mode 100644 index 0000000..604d740 --- /dev/null +++ b/dta/mybtn.h @@ -0,0 +1,32 @@ +#ifndef MYBTN_H +#define MYBTN_H + +#include +#include +#include +#include +#include +class mybtn : public QPushButton +{ + Q_OBJECT +public: + explicit mybtn(QPushButton *parent = nullptr); + + int tag,min,max; + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + QTimer* timer1; + QTimer* timer2; + bool flag; + int pox,poy; + void changeflag(); + void moveto(); +signals: + void toomany(); + void ok(); +public slots: + + void knowb(); +}; + +#endif // MYBTN_H diff --git a/dta/mylabel.cpp b/dta/mylabel.cpp new file mode 100644 index 0000000..0adbd03 --- /dev/null +++ b/dta/mylabel.cpp @@ -0,0 +1,242 @@ +#include "mylabel.h" +#include +#include +#include +#include + +mylabel::mylabel(int huan,int gao,QWidget *p) +{ + timer2= new QTimer(this); + timer3= new QTimer(this); + pa=p; + this->tag=1; + + this->changeflag(); + + + this->max=4; + this->min=1; + this->status=1; + //设置水平对其和垂直对其 + this->huan=huan; + this->gao=gao; + //初始化mylabel的大小 +// this->resize(huan,gao); + setbackcolor(status); +// this->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + + +} + +//鼠标进入 +void mylabel::enterEvent(QEvent *event) +{ + setbackcolor(this->status); + timer1= new QTimer(this); + //启动定时器 + //qDebug()<<"进入"; + timer1->start(1500); + connect(timer1,&QTimer::timeout,this,[=]() + { + //qDebug()<<"我在这"; + QLabel pic; + QPixmap pixmap =QPixmap(QString(":/res/%1.png").arg(this->id)); + + this->setFixedSize(400,200); + this->moveto(x,y);//居中显示 + pixmap=pixmap.scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + //qDebug()<status; + this->setIcon(pixmap); + this->raise(); + this->setIconSize(pixmap.size()); + + }); + +// return QLabel::enterEvent(event); +} + +//鼠标离开 +void mylabel::leaveEvent(QEvent *event) +{ +// //qDebug()<<"鼠标离开"; + timer1->stop(); + delete timer1; + //qDebug()<setbackcolor(status); +} + + +//鼠标点击 +void mylabel::mousePressEvent(QMouseEvent *ev) +{ + timer1->stop(); + timer1->start(2000); +// qDebug()<start(50); + // emit startp(this->id); + if(ev->button()==Qt::LeftButton) + { + //设置动画 + //qDebug()<<"左键"; + timer3->start(50); + this->status=2; + // setbackcolor(status); + emit startp(this->id); + } + if(ev->button()==Qt::RightButton) + { + + //启动定时器 + //qDebug()<<"右键"; + timer2->start(50); + this->status=3; + // setbackcolor(status); + emit endp(this->id); + } + } + else { + emit this->toomany(); + return; + } +} + +void mylabel::mouseReleaseEvent(QMouseEvent *ev) +{ +// timer3->stop(); + //qDebug()<<"释放"; + //qDebug()<tag=0; + qDebug()<<"wozao"; + } + if(tag==0) + { + this->tag=1; + qDebug()<<"wozao21"; + } +} + + + +//自定义mylabel的移动 +void mylabel::moveto(int x, int y) +{ + this->move(x-this->width()*0.5,y-this->height()*0.5); +} + + +//设置背景色,1,2,3,代表,无色,起点色,终点色,状态色 +void mylabel::setbackcolor(int i) +{ + if(i==1) + { + //qDebug()<huan; + QPixmap pixmap =QPixmap(QString(":/qita/res/qita/touming.png")); + this->setFixedSize(pixmap.width(),pixmap.height()); +// this->huan=pixmap.width(); +// this->gao=pixmap.height(); + this->setStyleSheet("QPushButton{border:0px;}"); + //qDebug()<status; + this->setIcon(pixmap); + this->setIconSize(pixmap.size()); + this->moveto(x,y); +// this->show(); + + } + else if (i==2) { + QPixmap pixmap =QPixmap(QString(":/qita/res/qita/q1.png")); + this->setFixedSize(pixmap.width(),pixmap.height()); +// this->huan=pixmap.width(); +// this->gao=pixmap.height(); + this->setStyleSheet("QPushButton{border:0px;}"); + //qDebug()<status; + this->setIcon(pixmap); + this->setIconSize(pixmap.size()); + this->moveto(x,y); +// this->show(); + + } + else if(i==3){ + QPixmap pixmap =QPixmap(QString(":/qita/res/qita/z1.png")); + this->setFixedSize(pixmap.width(),pixmap.height()); +// this->huan=pixmap.width(); +// this->gao=pixmap.height(); + this->setStyleSheet("QPushButton{border:0px;}"); + //qDebug()<status; + this->setIcon(pixmap); + this->setIconSize(pixmap.size()); + this->moveto(x,y); +// this->show(); + } +} + +void mylabel::changeflag() +{ + + connect(timer3,&QTimer::timeout,[=]() + { +// //qDebug()<min++); + pixmap.load(str); +// this->resize(pixmap.width(),pixmap.height()); + this->setFixedSize(pixmap.size()); + this->moveto(x,y);//居中显示 + //qDebug()<status; + //qDebug()<status; + this->setIcon(pixmap); + this->setStyleSheet("QPushButton{border:0px;}"); + this->setIconSize(pixmap.size()); + //qDebug()<<"左键重置"; + //qDebug()<width()<<" "<height(); + if(min>4) + { + this->min=1; + setbackcolor(status); + timer3->stop(); + } + } +); + connect(timer2,&QTimer::timeout,[=]() + { + QPixmap pixmap; + //设置起点状态 + QString str= QString(":/qita/res/qita/z%1.png").arg(this->min++); + pixmap.load(str); +// pixmap= pixmap.scaled(huan,gao, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + this->setFixedSize(pixmap.width(),pixmap.height()); + this->moveto(x,y); + this->setIcon(pixmap); + //qDebug()<status; + this->setStyleSheet("QPushButton{border:0px;}"); + this->setIconSize(pixmap.size()); + //qDebug()<width()<<" "<height(); + if(min>4) + { + //qDebug()<<"右键重置"; + this->min=1; + setbackcolor(status); + timer2->stop(); + } + }); + + + +} +//设置背景色 + + diff --git a/dta/mylabel.h b/dta/mylabel.h new file mode 100644 index 0000000..5f365b1 --- /dev/null +++ b/dta/mylabel.h @@ -0,0 +1,72 @@ +#ifndef MYLABEL_H +#define MYLABEL_H + +#include +#include +#include +#include +class mylabel : public QPushButton +{ + Q_OBJECT +public: +// explicit mylabel(QLabel *parent = nullptr); + //label的宽高构造函数 + + mylabel(int huan,int gao,QWidget *p=NULL); + + //parent指针 + QWidget *pa; + //鼠标进入事件 + void enterEvent(QEvent *event); + //离开事件 + void leaveEvent(QEvent *event); + + void mousePressEvent(QMouseEvent *ev); + + void mouseReleaseEvent(QMouseEvent *ev); + //设置动画 + void changeflag(); + QTimer* timer2; + QTimer* timer3; + + //图标的最大和最小 + int min,max; + //移动至x,y,居中显示 + void moveto(int x,int y); + + //设置宽高 + int huan,gao; + + //设置id + int id; + //设置周边界限 + int minx,maxx,miny,maxy; + + //设置状态位1,2,3,表示,随便结点,起点,终点 + int status; + + //设置一个名字 + QString name; + //定时器 + QTimer *timer1; + + + //设置背景色,1,2,3,代表,无色,起点色,终点色 + void setbackcolor(int i); + + //设置x,y + int x,y; + + + //封锁键盘 + int tag; +signals: + void startp(int i); + void endp(int i); + void toomany(); + +public slots: + void changetag(); +}; + +#endif // MYLABEL_H diff --git a/dta/mysound.cpp b/dta/mysound.cpp new file mode 100644 index 0000000..fa9363b --- /dev/null +++ b/dta/mysound.cpp @@ -0,0 +1,144 @@ +#include "mysound.h" + +#include + + +mysound::mysound(QWidget *parent):QWidget(parent) +{ +// tag=0; + // this->audio(); +} + +//mysound::mysound(MainWindow *parent) +//{ +// connect(parent->go,&mybtn::clicked,[&]() +// { +// this->tag=1; +// }); +//} + +//mysound::mysound() +//{ + +//} + +mysound::~mysound() +{ +} + +void mysound::stop() +{ + +} + +void mysound::start() +{ + + this->audio(); +} + +void mysound::audio() +{ + soudlist<finish(); + + + +//// //先从...出发 +//// sound = new QSound(":/audio/res/audio/xiancong.wav",this); +//// sound->play(); + +// //判断是否播放完 +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); + +// } +// delete sound; + +// sound = new QSound(QString(":/audio/res/audio/%1.wav").arg(list.at(0).toInt()),this); +// if(sound!=NULL&& tag!=1) +// { +// sound->play(); +// } +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } +// qDebug()<play();} +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } +// delete sound; +// sound = new QSound(QString(":/audio/res/audio/%1.wav").arg(list.at(i).toInt()),this); +// if(sound!=NULL&& tag!=1) +// { sound->play();} +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } +// delete sound; +// //qDebug()<play();} +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } +// sound = new QSound(QString(":/audio/res/audio/%1.wav").arg(list.at(list.length()-1).toInt()),this); +// if(sound!=NULL&& tag!=1) +// {sound->play();} +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } +// delete sound; +// //Over +// sound = new QSound(QString(":/audio/res/audio/over.wav"),this); +// if(sound!=NULL&& tag!=1) +// { sound->play(); +// qDebug()<tag;} +// while(!sound->isFinished()) +// { +// QCoreApplication::processEvents(); +// } + // delete sound; +} + +//void mysound::settag() +//{ +// if(tag==0) +// { +// tag=1; +// } + +//} diff --git a/dta/mysound.h b/dta/mysound.h new file mode 100644 index 0000000..5f1c933 --- /dev/null +++ b/dta/mysound.h @@ -0,0 +1,36 @@ +#ifndef MYSOUND_H +#define MYSOUND_H +#include +#include +#include +#include +#include +class mysound: public QWidget +{ +public: + mysound(QWidget *parent = nullptr); + +// mysound( * parent); + ~mysound(); + + //停止 + void stop(); + + //路线 + void start(); + QStringList list; + QStringList soudlist; + void audio(); + QSound *sound=NULL; + + + //设置tag +// void settag(); + //设置tag,判断中断 + int tag; +signals: + void finish(); + +}; + +#endif // MYSOUND_H diff --git a/dta/mysounds.cpp b/dta/mysounds.cpp new file mode 100644 index 0000000..0754cf9 --- /dev/null +++ b/dta/mysounds.cpp @@ -0,0 +1,35 @@ +#include "mysounds.h" + +#include + +mysounds::mysounds(QWidget *parent) : QWidget(parent) +{ + +} + +void mysounds::audio() +{ + emit begin(); + soudlist<finish(); +} diff --git a/dta/mysounds.h b/dta/mysounds.h new file mode 100644 index 0000000..6b5b993 --- /dev/null +++ b/dta/mysounds.h @@ -0,0 +1,24 @@ +#ifndef MYSOUNDS_H +#define MYSOUNDS_H + +#include +#include +#include +class mysounds : public QWidget +{ + Q_OBJECT +public: + explicit mysounds(QWidget *parent = nullptr); + QStringList list; + QStringList soudlist; + void audio(); + QSound *sound=NULL; + +signals: + void finish(); + void begin(); +public slots: + +}; + +#endif // MYSOUNDS_H diff --git a/dta/mytext.cpp b/dta/mytext.cpp new file mode 100644 index 0000000..eedafb0 --- /dev/null +++ b/dta/mytext.cpp @@ -0,0 +1,6 @@ +#include "mytext.h" + +MyText::MyText() +{ + +} diff --git a/dta/mytext.h b/dta/mytext.h new file mode 100644 index 0000000..252cb87 --- /dev/null +++ b/dta/mytext.h @@ -0,0 +1,16 @@ +#ifndef MYTEXT_H +#define MYTEXT_H +#include + +class MyText : public QTextBrowser +{ + Q_OBJECT +public: + MyText(); + +signals: + +public slots: +}; + +#endif // MYTEXT_H diff --git a/dta/mythread.cpp b/dta/mythread.cpp new file mode 100644 index 0000000..07de9d0 --- /dev/null +++ b/dta/mythread.cpp @@ -0,0 +1,7 @@ +#include "mythread.h" + +mythread::mythread() +{ + + +} diff --git a/dta/mythread.h b/dta/mythread.h new file mode 100644 index 0000000..66ff63f --- /dev/null +++ b/dta/mythread.h @@ -0,0 +1,17 @@ +#ifndef MYTHREAD_H +#define MYTHREAD_H +#include +#include + +class mythread : public QThread +{ + Q_OBJECT +public: + mythread(QStringList ); + +signals: + +public slots: +}; + +#endif // MYTHREAD_H diff --git a/dta/point.cpp b/dta/point.cpp new file mode 100644 index 0000000..31ebe30 --- /dev/null +++ b/dta/point.cpp @@ -0,0 +1,7 @@ +#include "point.h" + +Point::Point() +{ + + +} diff --git a/dta/point.h b/dta/point.h new file mode 100644 index 0000000..4acb33d --- /dev/null +++ b/dta/point.h @@ -0,0 +1,13 @@ +#ifndef POINT_H +#define POINT_H + + +class Point +{ +public: + Point(); + int x,y; + int +}; + +#endif // POINT_H diff --git a/dta/qtextbrowser.cpp b/dta/qtextbrowser.cpp new file mode 100644 index 0000000..d0e62c2 --- /dev/null +++ b/dta/qtextbrowser.cpp @@ -0,0 +1,6 @@ +#include "qtextbrowser.h" + +QTextBrowser::QTextBrowser(QWidget *parent) : QWidget(parent) +{ + +} diff --git a/dta/qtextbrowser.h b/dta/qtextbrowser.h new file mode 100644 index 0000000..8efa0be --- /dev/null +++ b/dta/qtextbrowser.h @@ -0,0 +1,17 @@ +#ifndef QTEXTBROWSER_H +#define QTEXTBROWSER_H + +#include + +class QTextBrowser : public QWidget +{ + Q_OBJECT +public: + explicit QTextBrowser(QWidget *parent = nullptr); + +signals: + +public slots: +}; + +#endif // QTEXTBROWSER_H diff --git a/dta/res.qrc b/dta/res.qrc new file mode 100644 index 0000000..8ba1042 --- /dev/null +++ b/dta/res.qrc @@ -0,0 +1,77 @@ + + + res/map.png + res/21.png + res/Point.csv + res/1.png + res/2.png + res/3.png + res/4.png + res/5.png + res/6.png + res/7.png + res/8.png + res/9.png + res/10.png + res/11.png + res/12.png + res/13.png + res/14.png + res/15.png + res/16.png + res/17.png + res/18.png + res/19.png + res/20.png + res/22.png + res/dis.csv + res/ysu.png + res/logo.ico + + + res/audio/1.wav + res/audio/2.wav + res/audio/3.wav + res/audio/4.wav + res/audio/5.wav + res/audio/6.wav + res/audio/7.wav + res/audio/8.wav + res/audio/9.wav + res/audio/10.wav + res/audio/11.wav + res/audio/12.wav + res/audio/13.wav + res/audio/14.wav + res/audio/15.wav + res/audio/16.wav + res/audio/17.wav + res/audio/18.wav + res/audio/19.wav + res/audio/20.wav + res/audio/21.wav + res/audio/22.wav + res/audio/arrive.wav + res/audio/start.wav + res/audio/through.wav + res/audio/xiancong.wav + res/audio/over.wav + + + + res/qita/daohang.png + res/qita/q1.png + res/qita/q2.png + res/qita/q3.png + res/qita/q4.png + res/qita/z1.png + res/qita/z2.png + res/qita/z3.png + res/qita/z4.png + res/qita/start2.png + res/qita/start3.png + res/qita/start4.png + res/qita/start1.png + res/qita/touming.png + + diff --git a/dta/res/1.png b/dta/res/1.png new file mode 100644 index 0000000..f2390a0 Binary files /dev/null and b/dta/res/1.png differ diff --git a/dta/res/10.png b/dta/res/10.png new file mode 100644 index 0000000..1e4ec74 Binary files /dev/null and b/dta/res/10.png differ diff --git a/dta/res/11.png b/dta/res/11.png new file mode 100644 index 0000000..3faea4c Binary files /dev/null and b/dta/res/11.png differ diff --git a/dta/res/12.png b/dta/res/12.png new file mode 100644 index 0000000..404d43f Binary files /dev/null and b/dta/res/12.png differ diff --git a/dta/res/13.png b/dta/res/13.png new file mode 100644 index 0000000..b297d32 Binary files /dev/null and b/dta/res/13.png differ diff --git a/dta/res/14.png b/dta/res/14.png new file mode 100644 index 0000000..171251f Binary files /dev/null and b/dta/res/14.png differ diff --git a/dta/res/15.png b/dta/res/15.png new file mode 100644 index 0000000..6462764 Binary files /dev/null and b/dta/res/15.png differ diff --git a/dta/res/16.png b/dta/res/16.png new file mode 100644 index 0000000..2e4c7e8 Binary files /dev/null and b/dta/res/16.png differ diff --git a/dta/res/17.png b/dta/res/17.png new file mode 100644 index 0000000..d7e81cf Binary files /dev/null and b/dta/res/17.png differ diff --git a/dta/res/18.png b/dta/res/18.png new file mode 100644 index 0000000..1006a0e Binary files /dev/null and b/dta/res/18.png differ diff --git a/dta/res/19.png b/dta/res/19.png new file mode 100644 index 0000000..241c609 Binary files /dev/null and b/dta/res/19.png differ diff --git a/dta/res/2.png b/dta/res/2.png new file mode 100644 index 0000000..a6c7dea Binary files /dev/null and b/dta/res/2.png differ diff --git a/dta/res/20.png b/dta/res/20.png new file mode 100644 index 0000000..10a2b42 Binary files /dev/null and b/dta/res/20.png differ diff --git a/dta/res/21.png b/dta/res/21.png new file mode 100644 index 0000000..e053d7e Binary files /dev/null and b/dta/res/21.png differ diff --git a/dta/res/22.png b/dta/res/22.png new file mode 100644 index 0000000..3d06ac0 Binary files /dev/null and b/dta/res/22.png differ diff --git a/dta/res/3.png b/dta/res/3.png new file mode 100644 index 0000000..7cf4971 Binary files /dev/null and b/dta/res/3.png differ diff --git a/dta/res/4.png b/dta/res/4.png new file mode 100644 index 0000000..0cc8cbd Binary files /dev/null and b/dta/res/4.png differ diff --git a/dta/res/5.png b/dta/res/5.png new file mode 100644 index 0000000..88c14ee Binary files /dev/null and b/dta/res/5.png differ diff --git a/dta/res/6.png b/dta/res/6.png new file mode 100644 index 0000000..e2dfe9e Binary files /dev/null and b/dta/res/6.png differ diff --git a/dta/res/7.png b/dta/res/7.png new file mode 100644 index 0000000..fe03ff9 Binary files /dev/null and b/dta/res/7.png differ diff --git a/dta/res/8.png b/dta/res/8.png new file mode 100644 index 0000000..51055de Binary files /dev/null and b/dta/res/8.png differ diff --git a/dta/res/9.png b/dta/res/9.png new file mode 100644 index 0000000..b88fc73 Binary files /dev/null and b/dta/res/9.png differ diff --git a/dta/res/Point.csv b/dta/res/Point.csv new file mode 100644 index 0000000..5614d0e --- /dev/null +++ b/dta/res/Point.csv @@ -0,0 +1,22 @@ +1,东区2号门,825,666,800,854,638,694 +2,东大活,546,621,519,571,594,648 +3,燕宏桥,722,480,693,749,454,510 +4,燕大小区,913,559,886,942,531,587 +5,信息馆,834,419,808,862,390,447 +6,第二体育场,1000,439,973,1028,409,466 +7,1号门,611,684,583,639,656,711 +8,世纪楼图书馆,619,577,593,647,548,606 +9,第一体育场,493,665,469,520,634,692 +10,雁鸣湖食堂,439,568,413,467,541,597 +11,西区大门,117,507,90,144,480,534 +12,里仁学院,267,428,242,292,403,452 +13,12345组团,73,410,46,96,385,437 +14,西区大食堂,178,306,151,204,279,332 +15,11组团,156,149,130,183,122,175 +16,广源超市,63,227,37,90,198,251 +17,燕园,231,165,204,258,138,192 +18,西区教学楼,406,244,379,433,217,271 +19,塔山,564,359,536,591,330,387 +20,西五教学楼,433,105,406,460,78,132 +21,第四体育场,240,43,213,267,16,70 +22,西大活,319,499,292,346,472,526 diff --git a/dta/res/audio/1.wav b/dta/res/audio/1.wav new file mode 100644 index 0000000..754d0aa Binary files /dev/null and b/dta/res/audio/1.wav differ diff --git a/dta/res/audio/10.wav b/dta/res/audio/10.wav new file mode 100644 index 0000000..8726f7d Binary files /dev/null and b/dta/res/audio/10.wav differ diff --git a/dta/res/audio/11.wav b/dta/res/audio/11.wav new file mode 100644 index 0000000..b62c3ba Binary files /dev/null and b/dta/res/audio/11.wav differ diff --git a/dta/res/audio/12.wav b/dta/res/audio/12.wav new file mode 100644 index 0000000..b0996bc Binary files /dev/null and b/dta/res/audio/12.wav differ diff --git a/dta/res/audio/13.wav b/dta/res/audio/13.wav new file mode 100644 index 0000000..c7479bd Binary files /dev/null and b/dta/res/audio/13.wav differ diff --git a/dta/res/audio/14.wav b/dta/res/audio/14.wav new file mode 100644 index 0000000..23b7c12 Binary files /dev/null and b/dta/res/audio/14.wav differ diff --git a/dta/res/audio/15.wav b/dta/res/audio/15.wav new file mode 100644 index 0000000..fa8c1ed Binary files /dev/null and b/dta/res/audio/15.wav differ diff --git a/dta/res/audio/16.wav b/dta/res/audio/16.wav new file mode 100644 index 0000000..8b75cae Binary files /dev/null and b/dta/res/audio/16.wav differ diff --git a/dta/res/audio/17.wav b/dta/res/audio/17.wav new file mode 100644 index 0000000..09d49d1 Binary files /dev/null and b/dta/res/audio/17.wav differ diff --git a/dta/res/audio/18.wav b/dta/res/audio/18.wav new file mode 100644 index 0000000..985a352 Binary files /dev/null and b/dta/res/audio/18.wav differ diff --git a/dta/res/audio/19.wav b/dta/res/audio/19.wav new file mode 100644 index 0000000..c9f2433 Binary files /dev/null and b/dta/res/audio/19.wav differ diff --git a/dta/res/audio/2.wav b/dta/res/audio/2.wav new file mode 100644 index 0000000..c786aa7 Binary files /dev/null and b/dta/res/audio/2.wav differ diff --git a/dta/res/audio/20.wav b/dta/res/audio/20.wav new file mode 100644 index 0000000..645d957 Binary files /dev/null and b/dta/res/audio/20.wav differ diff --git a/dta/res/audio/21.wav b/dta/res/audio/21.wav new file mode 100644 index 0000000..e486bbc Binary files /dev/null and b/dta/res/audio/21.wav differ diff --git a/dta/res/audio/22.wav b/dta/res/audio/22.wav new file mode 100644 index 0000000..bc44cc3 Binary files /dev/null and b/dta/res/audio/22.wav differ diff --git a/dta/res/audio/3.wav b/dta/res/audio/3.wav new file mode 100644 index 0000000..e53ecd5 Binary files /dev/null and b/dta/res/audio/3.wav differ diff --git a/dta/res/audio/4.wav b/dta/res/audio/4.wav new file mode 100644 index 0000000..4ad1fa4 Binary files /dev/null and b/dta/res/audio/4.wav differ diff --git a/dta/res/audio/5.wav b/dta/res/audio/5.wav new file mode 100644 index 0000000..eed268b Binary files /dev/null and b/dta/res/audio/5.wav differ diff --git a/dta/res/audio/6.wav b/dta/res/audio/6.wav new file mode 100644 index 0000000..7a2835f Binary files /dev/null and b/dta/res/audio/6.wav differ diff --git a/dta/res/audio/7.wav b/dta/res/audio/7.wav new file mode 100644 index 0000000..398b5a5 Binary files /dev/null and b/dta/res/audio/7.wav differ diff --git a/dta/res/audio/8.wav b/dta/res/audio/8.wav new file mode 100644 index 0000000..29dad7a Binary files /dev/null and b/dta/res/audio/8.wav differ diff --git a/dta/res/audio/9.wav b/dta/res/audio/9.wav new file mode 100644 index 0000000..092685e Binary files /dev/null and b/dta/res/audio/9.wav differ diff --git a/dta/res/audio/arrive.wav b/dta/res/audio/arrive.wav new file mode 100644 index 0000000..36bfada Binary files /dev/null and b/dta/res/audio/arrive.wav differ diff --git a/dta/res/audio/over.wav b/dta/res/audio/over.wav new file mode 100644 index 0000000..acb59d0 Binary files /dev/null and b/dta/res/audio/over.wav differ diff --git a/dta/res/audio/start.wav b/dta/res/audio/start.wav new file mode 100644 index 0000000..a7adcd3 Binary files /dev/null and b/dta/res/audio/start.wav differ diff --git a/dta/res/audio/through.wav b/dta/res/audio/through.wav new file mode 100644 index 0000000..528408b Binary files /dev/null and b/dta/res/audio/through.wav differ diff --git a/dta/res/audio/xiancong.wav b/dta/res/audio/xiancong.wav new file mode 100644 index 0000000..de91748 Binary files /dev/null and b/dta/res/audio/xiancong.wav differ diff --git a/dta/res/dis.csv b/dta/res/dis.csv new file mode 100644 index 0000000..36819d0 --- /dev/null +++ b/dta/res/dis.csv @@ -0,0 +1,44 @@ +1,2,720 +1,3,760 +1,4,310 +1,8,680 +2,8,170 +2,9,100 +2,10,230 +3,4,630 +3,5,180 +3,6,570 +3,8,460 +3,10,830 +3,19,540 +4,6,320 +5,6,300 +7,8,230 +7,9,180 +8,10,330 +9,10,230 +11,12,500 +11,13,300 +11,22,500 +12,13,510 +12,14,380 +12,17,850 +12,18,730 +12,19,800 +12,22,100 +13,14,400 +13,16,800 +14,16,300 +14,17,430 +14,18,710 +15,16,150 +15,17,50 +15,21,450 +16,17,200 +17,18,630 +17,20,850 +17,21,410 +18,19,580 +18,20,520 +19,22,820 +20,21,500 diff --git a/dta/res/logo.ico b/dta/res/logo.ico new file mode 100644 index 0000000..0e7ec63 Binary files /dev/null and b/dta/res/logo.ico differ diff --git a/dta/res/map.png b/dta/res/map.png new file mode 100644 index 0000000..23ca833 Binary files /dev/null and b/dta/res/map.png differ diff --git a/dta/res/qita/daohang.png b/dta/res/qita/daohang.png new file mode 100644 index 0000000..c84b116 Binary files /dev/null and b/dta/res/qita/daohang.png differ diff --git a/dta/res/qita/q1.png b/dta/res/qita/q1.png new file mode 100644 index 0000000..6565436 Binary files /dev/null and b/dta/res/qita/q1.png differ diff --git a/dta/res/qita/q2.png b/dta/res/qita/q2.png new file mode 100644 index 0000000..0999922 Binary files /dev/null and b/dta/res/qita/q2.png differ diff --git a/dta/res/qita/q3.png b/dta/res/qita/q3.png new file mode 100644 index 0000000..95f5188 Binary files /dev/null and b/dta/res/qita/q3.png differ diff --git a/dta/res/qita/q4.png b/dta/res/qita/q4.png new file mode 100644 index 0000000..3fe21e2 Binary files /dev/null and b/dta/res/qita/q4.png differ diff --git a/dta/res/qita/start1.png b/dta/res/qita/start1.png new file mode 100644 index 0000000..9bd00e4 Binary files /dev/null and b/dta/res/qita/start1.png differ diff --git a/dta/res/qita/start2.png b/dta/res/qita/start2.png new file mode 100644 index 0000000..42c51fe Binary files /dev/null and b/dta/res/qita/start2.png differ diff --git a/dta/res/qita/start3.png b/dta/res/qita/start3.png new file mode 100644 index 0000000..698b299 Binary files /dev/null and b/dta/res/qita/start3.png differ diff --git a/dta/res/qita/start4.png b/dta/res/qita/start4.png new file mode 100644 index 0000000..d8532f4 Binary files /dev/null and b/dta/res/qita/start4.png differ diff --git a/dta/res/qita/touming.png b/dta/res/qita/touming.png new file mode 100644 index 0000000..616c143 Binary files /dev/null and b/dta/res/qita/touming.png differ diff --git a/dta/res/qita/z1.png b/dta/res/qita/z1.png new file mode 100644 index 0000000..ea0d335 Binary files /dev/null and b/dta/res/qita/z1.png differ diff --git a/dta/res/qita/z2.png b/dta/res/qita/z2.png new file mode 100644 index 0000000..2fe8aa4 Binary files /dev/null and b/dta/res/qita/z2.png differ diff --git a/dta/res/qita/z3.png b/dta/res/qita/z3.png new file mode 100644 index 0000000..a85b9b3 Binary files /dev/null and b/dta/res/qita/z3.png differ diff --git a/dta/res/qita/z4.png b/dta/res/qita/z4.png new file mode 100644 index 0000000..01a779c Binary files /dev/null and b/dta/res/qita/z4.png differ diff --git a/dta/res/ysu.png b/dta/res/ysu.png new file mode 100644 index 0000000..e03a44b Binary files /dev/null and b/dta/res/ysu.png differ diff --git a/file/file.pro b/file/file.pro new file mode 100644 index 0000000..9a5aecf --- /dev/null +++ b/file/file.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T14:22:06 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = file +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/file/main.cpp b/file/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/file/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/file/widget.cpp b/file/widget.cpp new file mode 100644 index 0000000..e0e03cc --- /dev/null +++ b/file/widget.cpp @@ -0,0 +1,52 @@ +#include "widget.h" +#include "ui_widget.h" +#include +#include +#include +#include + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + //点击信号选择文件 + + connect(ui->select,&QPushButton::clicked,[=]() + { + QString path =QFileDialog::getOpenFileName(this,"打开文件","C:\\Users\\Administrator\\Desktop"); + + //将路径放入lineedit + ui->lineEdit->setText(path); + QTextCodec *codec=QTextCodec::codecForName("GBK"); + + //Qt默认支持utf8 + + //读取内容,放入textedit + QFile file(path); //读取文件的地址 + file.open(QIODevice::ReadOnly); + QByteArray array; + while(!file.atEnd()) + {array= file.readLine(); + array +=file.readLine(); + } + ui->textEdit->setText(array); + //ui->textEdit->setText(array); + + //写文件 + file.close(); + file.open(QIODevice::Append); + file.write("aaaa"); + file.close(); + }); + + + + + +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/file/widget.h b/file/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/file/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/file/widget.ui b/file/widget.ui new file mode 100644 index 0000000..af536e4 --- /dev/null +++ b/file/widget.ui @@ -0,0 +1,41 @@ + + + Widget + + + + 0 + 0 + 721 + 554 + + + + Widget + + + + + + + + + + + + Select + + + + + + + + + + + + + + + diff --git a/fist1/fist1.pro b/fist1/fist1.pro new file mode 100644 index 0000000..dae4fc4 --- /dev/null +++ b/fist1/fist1.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:23:39 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = fist1 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + form.cpp + +HEADERS += \ + widget.h \ + form.h + +FORMS += \ + widget.ui \ + form.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/fist1/form.cpp b/fist1/form.cpp new file mode 100644 index 0000000..20e6af2 --- /dev/null +++ b/fist1/form.cpp @@ -0,0 +1,14 @@ +#include "form.h" +#include "ui_form.h" + +Form::Form(QWidget *parent) : + QWidget(parent), + ui(new Ui::Form) +{ + ui->setupUi(this); +} + +Form::~Form() +{ + delete ui; +} diff --git a/fist1/form.h b/fist1/form.h new file mode 100644 index 0000000..3a278e4 --- /dev/null +++ b/fist1/form.h @@ -0,0 +1,22 @@ +#ifndef FORM_H +#define FORM_H + +#include + +namespace Ui { +class Form; +} + +class Form : public QWidget +{ + Q_OBJECT + +public: + explicit Form(QWidget *parent = nullptr); + ~Form(); + +private: + Ui::Form *ui; +}; + +#endif // FORM_H diff --git a/fist1/form.ui b/fist1/form.ui new file mode 100644 index 0000000..b02b7f6 --- /dev/null +++ b/fist1/form.ui @@ -0,0 +1,42 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 200 + 150 + 160 + 22 + + + + Qt::Horizontal + + + + + + 100 + 150 + 46 + 22 + + + + + + + diff --git a/fist1/main.cpp b/fist1/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/fist1/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/fist1/widget.cpp b/fist1/widget.cpp new file mode 100644 index 0000000..e3dc37d --- /dev/null +++ b/fist1/widget.cpp @@ -0,0 +1,14 @@ +#include "widget.h" +#include "ui_widget.h" + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/fist1/widget.h b/fist1/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/fist1/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/fist1/widget.ui b/fist1/widget.ui new file mode 100644 index 0000000..875ad49 --- /dev/null +++ b/fist1/widget.ui @@ -0,0 +1,38 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + 19 + 100 + 321 + 80 + + + + + + + + form + QWidget +
form.h
+ 1 +
+
+ + +
diff --git a/huihu/huihu.pro b/huihu/huihu.pro new file mode 100644 index 0000000..bf4fb96 --- /dev/null +++ b/huihu/huihu.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T11:28:03 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = huihu +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + image/res.qrc diff --git a/huihu/image/C.png b/huihu/image/C.png new file mode 100644 index 0000000..7bdc74f Binary files /dev/null and b/huihu/image/C.png differ diff --git a/huihu/image/Office.png b/huihu/image/Office.png new file mode 100644 index 0000000..caec635 Binary files /dev/null and b/huihu/image/Office.png differ diff --git a/huihu/image/R.gif b/huihu/image/R.gif new file mode 100644 index 0000000..11eb515 Binary files /dev/null and b/huihu/image/R.gif differ diff --git a/huihu/image/cpp.png b/huihu/image/cpp.png new file mode 100644 index 0000000..973d118 Binary files /dev/null and b/huihu/image/cpp.png differ diff --git a/huihu/image/jie.jpg b/huihu/image/jie.jpg new file mode 100644 index 0000000..a572ce8 Binary files /dev/null and b/huihu/image/jie.jpg differ diff --git a/huihu/image/res.qrc b/huihu/image/res.qrc new file mode 100644 index 0000000..79877c8 --- /dev/null +++ b/huihu/image/res.qrc @@ -0,0 +1,10 @@ + + + C.png + cpp.png + jie.jpg + Office.png + R.gif + youtube-logo_1647079616164.png + + diff --git a/huihu/image/youtube-logo_1647079616164.png b/huihu/image/youtube-logo_1647079616164.png new file mode 100644 index 0000000..6531f1a Binary files /dev/null and b/huihu/image/youtube-logo_1647079616164.png differ diff --git a/huihu/main.cpp b/huihu/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/huihu/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/huihu/widget.cpp b/huihu/widget.cpp new file mode 100644 index 0000000..a065a0b --- /dev/null +++ b/huihu/widget.cpp @@ -0,0 +1,50 @@ +#include "widget.h" +#include "ui_widget.h" +#include +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + connect(ui->btn,&QPushButton::clicked,[=]() + { + posx+=20; + + //手动调用画图 + update(); + }); +} + +Widget::~Widget() +{ + delete ui; +} + + +void Widget::paintEvent(QPaintEvent * ) +{ +// //实例化一个画家 //指定的是当前画画的设备 +// QPainter painter(this); + +// QPen pen(QColor(255,0,0)); +// //让画家使用这个笔 +// pen.setWidth(3); +// painter.setPen(pen); + +// painter.drawLine(QPoint(0,0),QPoint(100,100)); +// painter.drawEllipse(QPoint(100,100),100,50); + +// //画一个矩形 +// painter.drawRect(QRect(100,100,50,50)); + +// //写文字 +// painter.drawText(QRect(10,200,100,50),"好好学习,天天向上"); + //用画家来画资源图片 + if(posx>this->width()) + { + posx=0; + } + QPainter painter(this); + painter.drawPixmap(posx,10,QPixmap(":/cpp.png")); + +} diff --git a/huihu/widget.h b/huihu/widget.h new file mode 100644 index 0000000..7a0a6a4 --- /dev/null +++ b/huihu/widget.h @@ -0,0 +1,26 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + + //绘图事件 + void paintEvent(QPaintEvent * ); + +private: + Ui::Widget *ui; + int posx; +}; + +#endif // WIDGET_H diff --git a/huihu/widget.ui b/huihu/widget.ui new file mode 100644 index 0000000..5339d94 --- /dev/null +++ b/huihu/widget.ui @@ -0,0 +1,33 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + 290 + 210 + 93 + 28 + + + + PushButton + + + + + + + diff --git a/smal/main.cpp b/smal/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/smal/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/smal/smal.pro b/smal/smal.pro new file mode 100644 index 0000000..f6e7563 --- /dev/null +++ b/smal/smal.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:29:15 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = smal +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + small.cpp + +HEADERS += \ + widget.h \ + small.h + +FORMS += \ + widget.ui \ + small.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/smal/small.cpp b/smal/small.cpp new file mode 100644 index 0000000..95b3315 --- /dev/null +++ b/smal/small.cpp @@ -0,0 +1,29 @@ +#include "small.h" +#include "ui_small.h" + +small::small(QWidget *parent) : + QWidget(parent), + ui(new Ui::small) +{ + ui->setupUi(this); + void(QSpinBox:: *sp)(int)= &QSpinBox::valueChanged; + void(QSlider:: *sl)(int)= &QSlider::valueChanged; + connect(ui->spinBox,sp,ui->horizontalSlider,&QSlider::setValue); + connect(ui->horizontalSlider,sl,ui->spinBox,&QSpinBox::setValue); + + +} + +small::~small() +{ + delete ui; +} +void small::setNum(int num){ + ui->spinBox->setValue(num); +} + +int small::getNum(){ + return ui->spinBox->value(); +} + + diff --git a/smal/small.h b/smal/small.h new file mode 100644 index 0000000..da8ebde --- /dev/null +++ b/smal/small.h @@ -0,0 +1,24 @@ +#ifndef SMALL_H +#define SMALL_H + +#include + +namespace Ui { +class small; +} + +class small : public QWidget +{ + Q_OBJECT + +public: + explicit small(QWidget *parent = nullptr); + ~small(); + void setNum(int num); + int getNum(); + +private: + Ui::small *ui; +}; + +#endif // SMALL_H diff --git a/smal/small.ui b/smal/small.ui new file mode 100644 index 0000000..5a1ed90 --- /dev/null +++ b/smal/small.ui @@ -0,0 +1,42 @@ + + + small + + + + 0 + 0 + 249 + 57 + + + + Form + + + + + 10 + 20 + 160 + 22 + + + + Qt::Horizontal + + + + + + 200 + 20 + 46 + 22 + + + + + + + diff --git a/smal/widget.cpp b/smal/widget.cpp new file mode 100644 index 0000000..b478135 --- /dev/null +++ b/smal/widget.cpp @@ -0,0 +1,25 @@ +#include "widget.h" +#include "ui_widget.h" +#include "QDebug" +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); + connect(ui->get,&QPushButton::clicked,[=]() + { + + qDebug()<widget->getNum(); + }); + + //设置到一半 + connect(ui->set,&QPushButton::clicked,[=]() + { + ui->widget->setNum(60); + }); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/smal/widget.h b/smal/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/smal/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/smal/widget.ui b/smal/widget.ui new file mode 100644 index 0000000..6646a47 --- /dev/null +++ b/smal/widget.ui @@ -0,0 +1,64 @@ + + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + 0 + 70 + 381 + 80 + + + + + + + 140 + 180 + 93 + 28 + + + + set + + + + + + 140 + 230 + 93 + 28 + + + + get + + + + + + + small + QWidget +
small.h
+ 1 +
+
+ + +
diff --git a/testss/he.cpp b/testss/he.cpp new file mode 100644 index 0000000..dc222aa --- /dev/null +++ b/testss/he.cpp @@ -0,0 +1,6 @@ +#include "he.h" + +he::he(QWidget *parent) : QWidget(parent) +{ + +} diff --git a/testss/he.h b/testss/he.h new file mode 100644 index 0000000..fca2de1 --- /dev/null +++ b/testss/he.h @@ -0,0 +1,18 @@ +#ifndef HE_H +#define HE_H + +#include +#include + +class he : public QWidget +{ + Q_OBJECT +public: + explicit he(QWidget *parent = nullptr); + +signals: + +public slots: +}; + +#endif // HE_H \ No newline at end of file diff --git a/testss/main.cpp b/testss/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/testss/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/testss/mainwindow.cpp b/testss/mainwindow.cpp new file mode 100644 index 0000000..12d07c0 --- /dev/null +++ b/testss/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/testss/mainwindow.h b/testss/mainwindow.h new file mode 100644 index 0000000..40fd472 --- /dev/null +++ b/testss/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/testss/mainwindow.ui b/testss/mainwindow.ui new file mode 100644 index 0000000..53dccaf --- /dev/null +++ b/testss/mainwindow.ui @@ -0,0 +1,40 @@ + + + MainWindow + + + + 0 + 0 + 570 + 465 + + + + MainWindow + + + + + + 0 + 0 + 570 + 26 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/testss/testss.pro b/testss/testss.pro new file mode 100644 index 0000000..b9691d1 --- /dev/null +++ b/testss/testss.pro @@ -0,0 +1,42 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-05T18:58:24 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = testss +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + he.cpp + +HEADERS += \ + mainwindow.h \ + he.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/zhidingyi/main.cpp b/zhidingyi/main.cpp new file mode 100644 index 0000000..4d6c97b --- /dev/null +++ b/zhidingyi/main.cpp @@ -0,0 +1,11 @@ +#include "widget.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/zhidingyi/widget.cpp b/zhidingyi/widget.cpp new file mode 100644 index 0000000..e3dc37d --- /dev/null +++ b/zhidingyi/widget.cpp @@ -0,0 +1,14 @@ +#include "widget.h" +#include "ui_widget.h" + +Widget::Widget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Widget) +{ + ui->setupUi(this); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/zhidingyi/widget.h b/zhidingyi/widget.h new file mode 100644 index 0000000..3543bb3 --- /dev/null +++ b/zhidingyi/widget.h @@ -0,0 +1,22 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +namespace Ui { +class Widget; +} + +class Widget : public QWidget +{ + Q_OBJECT + +public: + explicit Widget(QWidget *parent = nullptr); + ~Widget(); + +private: + Ui::Widget *ui; +}; + +#endif // WIDGET_H diff --git a/zhidingyi/widget.ui b/zhidingyi/widget.ui new file mode 100644 index 0000000..8c91283 --- /dev/null +++ b/zhidingyi/widget.ui @@ -0,0 +1,20 @@ + + Widget + + + + 0 + 0 + 400 + 300 + + + + Widget + + + + + + + diff --git a/zhidingyi/zhidingyi.pro b/zhidingyi/zhidingyi.pro new file mode 100644 index 0000000..2bd063c --- /dev/null +++ b/zhidingyi/zhidingyi.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:10:14 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = zhidingyi +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp + +HEADERS += \ + widget.h + +FORMS += \ + widget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/zidingy/main.cpp b/zidingy/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/zidingy/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/zidingy/mainwindow.cpp b/zidingy/mainwindow.cpp new file mode 100644 index 0000000..12d07c0 --- /dev/null +++ b/zidingy/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/zidingy/mainwindow.h b/zidingy/mainwindow.h new file mode 100644 index 0000000..40fd472 --- /dev/null +++ b/zidingy/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/zidingy/mainwindow.ui b/zidingy/mainwindow.ui new file mode 100644 index 0000000..313d907 --- /dev/null +++ b/zidingy/mainwindow.ui @@ -0,0 +1,59 @@ + + + MainWindow + + + + 0 + 0 + 676 + 507 + + + + MainWindow + + + + + + 110 + 90 + 411 + 91 + + + + + + + + 0 + 0 + 676 + 26 + + + + + + TopToolBarArea + + + false + + + + + + + + smallwidget + QWidget +
smallwidget.h
+ 1 +
+
+ + +
diff --git a/zidingy/smallwidget.cpp b/zidingy/smallwidget.cpp new file mode 100644 index 0000000..307b2ed --- /dev/null +++ b/zidingy/smallwidget.cpp @@ -0,0 +1,14 @@ +#include "smallwidget.h" +#include "ui_smallwidget.h" + +Smallwidget::Smallwidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::Smallwidget) +{ + ui->setupUi(this); +} + +Smallwidget::~Smallwidget() +{ + delete ui; +} diff --git a/zidingy/smallwidget.h b/zidingy/smallwidget.h new file mode 100644 index 0000000..42601de --- /dev/null +++ b/zidingy/smallwidget.h @@ -0,0 +1,22 @@ +#ifndef SMALLWIDGET_H +#define SMALLWIDGET_H + +#include + +namespace Ui { +class Smallwidget; +} + +class Smallwidget : public QWidget +{ + Q_OBJECT + +public: + explicit Smallwidget(QWidget *parent = nullptr); + ~Smallwidget(); + +private: + Ui::Smallwidget *ui; +}; + +#endif // SMALLWIDGET_H diff --git a/zidingy/smallwidget.ui b/zidingy/smallwidget.ui new file mode 100644 index 0000000..b715b9f --- /dev/null +++ b/zidingy/smallwidget.ui @@ -0,0 +1,31 @@ + + + Smallwidget + + + + 0 + 0 + 245 + 61 + + + + Form + + + + + + + + + Qt::Horizontal + + + + + + + + diff --git a/zidingy/zidingy.pro b/zidingy/zidingy.pro new file mode 100644 index 0000000..10a3951 --- /dev/null +++ b/zidingy/zidingy.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:11:52 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = zidingy +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + smallwidget.cpp + +HEADERS += \ + mainwindow.h \ + smallwidget.h + +FORMS += \ + mainwindow.ui \ + smallwidget.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/zidingyi/main.cpp b/zidingyi/main.cpp new file mode 100644 index 0000000..aab39bb --- /dev/null +++ b/zidingyi/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/zidingyi/mainwindow.cpp b/zidingyi/mainwindow.cpp new file mode 100644 index 0000000..12d07c0 --- /dev/null +++ b/zidingyi/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/zidingyi/mainwindow.h b/zidingyi/mainwindow.h new file mode 100644 index 0000000..40fd472 --- /dev/null +++ b/zidingyi/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/zidingyi/mainwindow.ui b/zidingyi/mainwindow.ui new file mode 100644 index 0000000..7de574d --- /dev/null +++ b/zidingyi/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/zidingyi/zidingyi.pro b/zidingyi/zidingyi.pro new file mode 100644 index 0000000..5d07f4c --- /dev/null +++ b/zidingyi/zidingyi.pro @@ -0,0 +1,40 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2022-04-02T09:11:05 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = zidingyi +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target