├── .gitattributes ├── .gitignore ├── Animation ├── QtAnimation.sln └── QtAnimation │ ├── MainWindow.qrc │ ├── QtAnimation.vcxproj │ ├── main.cpp │ └── ui │ └── MainWindow │ ├── MainWindow.cpp │ ├── MainWindow.h │ └── MainWindow.ui ├── Core ├── Excel十进制转为26进制 │ ├── 10to26.pro │ └── main.cpp ├── QGraphicsview_test │ ├── GraphicsViewTest.sln │ └── GraphicsViewTest │ │ ├── GeneratedFiles │ │ ├── Debug │ │ │ ├── moc_GraphicsViewTest.cpp │ │ │ └── moc_MainScene.cpp │ │ ├── qrc_GraphicsViewTest.cpp │ │ └── ui_GraphicsViewTest.h │ │ ├── GraphicsViewTest.cpp │ │ ├── GraphicsViewTest.h │ │ ├── GraphicsViewTest.qrc │ │ ├── GraphicsViewTest.ui │ │ ├── GraphicsViewTest.vcxproj │ │ ├── MainScene.cpp │ │ ├── MainScene.h │ │ └── main.cpp ├── QThreadPool │ ├── QThreadPool.pro │ ├── main.cpp │ ├── printtask.cpp │ └── printtask.h ├── Qt和C++11thread │ ├── ThreadTest.cpp │ ├── ThreadTest.h │ └── ThreadTest.ui ├── StaticCallbackTest │ ├── StaticCallBackTest.sln │ └── StaticCallBackTest │ │ ├── StaticCallBackTest.cpp │ │ ├── StaticCallBackTest.h │ │ ├── StaticCallBackTest.qrc │ │ ├── StaticCallBackTest.vcxproj │ │ └── main.cpp └── 字符串设置固定宽度,前位补0 │ └── 字符串设置固定宽度,前位补0.cc ├── Project ├── AppTranslation │ ├── AppTranslation.sln │ ├── AppTranslation │ │ ├── AppTranslation.vcxproj │ │ ├── AppTranslation.vcxproj.filters │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ ├── MainWindow.ui │ │ ├── TranslationSupport.h │ │ ├── Widget1.cpp │ │ ├── Widget1.h │ │ ├── Widget1.ui │ │ ├── Widget2.cpp │ │ ├── Widget2.h │ │ ├── Widget2.ui │ │ ├── apptranslation_en.qm │ │ ├── apptranslation_en.ts │ │ ├── apptranslation_zh.qm │ │ ├── apptranslation_zh.ts │ │ └── main.cpp │ └── gif.gif ├── DrawCircleAngleWindow │ ├── DrawCircleAngleWindow.sln │ └── DrawCircleAngleWindow │ │ ├── DrawCircleAngleWindow.vcxproj │ │ ├── MyWindow.cpp │ │ ├── MyWindow.h │ │ ├── MyWindow.qrc │ │ ├── MyWindow.ui │ │ └── main.cpp ├── QRCodeDemo │ ├── QRCodeDemo.sln │ ├── QRCodeDemo │ │ ├── QRCodeDemo.cpp │ │ ├── QRCodeDemo.h │ │ ├── QRCodeDemo.qrc │ │ ├── QRCodeDemo.ui │ │ ├── QRCodeDemo.vcxproj │ │ ├── QRCodeDemo.vcxproj.filters │ │ ├── main.cpp │ │ └── qrcode │ │ │ ├── bitstream.c │ │ │ ├── bitstream.h │ │ │ ├── config.h │ │ │ ├── mask.c │ │ │ ├── mask.h │ │ │ ├── mmask.c │ │ │ ├── mmask.h │ │ │ ├── mqrspec.c │ │ │ ├── mqrspec.h │ │ │ ├── qrencode.c │ │ │ ├── qrencode.h │ │ │ ├── qrencode_inner.h │ │ │ ├── qrinput.c │ │ │ ├── qrinput.h │ │ │ ├── qrspec.c │ │ │ ├── qrspec.h │ │ │ ├── rscode.c │ │ │ ├── rscode.h │ │ │ ├── split.c │ │ │ └── split.h │ └── result.png ├── QmlUseCppModel │ ├── QmlUseCppModel.sln │ └── QmlUseCppModel │ │ ├── CustomModel.cpp │ │ ├── CustomModel.h │ │ ├── QmlUseCppModel.qrc │ │ ├── QmlUseCppModel.vcxproj │ │ ├── QmlUseCppModel.vcxproj.filters │ │ └── main.cpp ├── QtAppCallQml │ ├── QtAppCallQml.sln │ └── QtAppCallQml │ │ ├── QtAppCallQml.qrc │ │ ├── QtAppCallQml.vcxproj │ │ ├── Resources │ │ └── main.qml │ │ └── main.cpp ├── QtFormDataDemo │ ├── QtFormDataDemo.sln │ ├── QtFormDataDemo.vcxproj │ ├── QtFormDataDemo.vcxproj.filters │ └── main.cpp ├── QtGuiApplication │ ├── CallBackTest │ │ ├── CallBackTest.qrc │ │ ├── CallBackTest.vcxproj │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ ├── MainWindow.ui │ │ ├── Square.cpp │ │ ├── Square.h │ │ └── main.cpp │ ├── QtGuiApplication.sln │ ├── SingleAppTest │ │ ├── SingleAppTest.cpp │ │ ├── SingleAppTest.h │ │ ├── SingleAppTest.qrc │ │ ├── SingleAppTest.ui │ │ ├── SingleAppTest.vcxproj │ │ └── main.cpp │ └── SingleAppTest2 │ │ ├── SingleAppTest2.cpp │ │ ├── SingleAppTest2.h │ │ ├── SingleAppTest2.qrc │ │ ├── SingleAppTest2.ui │ │ ├── SingleAppTest2.vcxproj │ │ └── main.cpp ├── VSQtUseQmlUi │ ├── VSQtUseQmlUi.sln │ ├── VSQtUseQmlUi │ │ ├── App.qrc │ │ ├── SwipeViewQml.qml │ │ ├── VSQtUseQmlUi.vcxproj │ │ ├── VSQtUseQmlUi.vcxproj.filters │ │ ├── Window.cpp │ │ ├── Window.h │ │ └── main.cpp │ └── 效果.gif └── WebTest │ ├── WebTest.sln │ └── WebTest │ ├── BMap.html │ ├── WebTest.cpp │ ├── WebTest.h │ ├── WebTest.ui │ ├── WebTest.vcxproj │ ├── main.cpp │ └── qwebchannel.js ├── PyQt ├── Python_CAD │ └── test.py ├── README.MD └── Tools │ └── CAD操作手册acadauto.chm ├── QSS ├── QCheckBox.qss ├── QPushButton.qss ├── QPushButtonQss │ ├── QPushButtonQss.pro │ ├── button.qss │ ├── dialog.cpp │ ├── dialog.h │ ├── dialog.ui │ └── main.cpp ├── QScrollBar.qss └── test.qss ├── QtExcel ├── ExcelManger.cpp ├── ExcelManger.h ├── QtExcel.pro ├── main.cpp ├── test.xlsx └── 副本test.xlsx ├── QtSQL ├── README ├── SqlTest │ ├── SqlTest.pro │ └── main.cpp └── SqliteReader │ ├── SqliteReader.cpp │ ├── SqliteReader.h │ ├── SqliteReader.sln │ ├── SqliteReader.vcxproj │ └── main.cpp ├── README.md ├── Tools ├── QtEmail │ ├── .gitignore │ ├── Email.pro │ ├── README.md │ ├── main.cpp │ └── src │ │ ├── mimeattachment.cpp │ │ ├── mimeattachment.h │ │ ├── mimecontentformatter.cpp │ │ ├── mimecontentformatter.h │ │ ├── mimefile.cpp │ │ ├── mimefile.h │ │ ├── mimehtml.cpp │ │ ├── mimehtml.h │ │ ├── mimeinlinefile.cpp │ │ ├── mimeinlinefile.h │ │ ├── mimemessage.cpp │ │ ├── mimemessage.h │ │ ├── mimemultipart.cpp │ │ ├── mimemultipart.h │ │ ├── mimepart.cpp │ │ ├── mimepart.h │ │ ├── mimetext.cpp │ │ ├── mimetext.h │ │ ├── publicdefine.h │ │ ├── quotedprintable.cpp │ │ ├── quotedprintable.h │ │ ├── smtpclient.cpp │ │ └── smtpclient.h ├── ReadMe └── ToolsMainWindow │ ├── Main.pro │ ├── README.md │ ├── pic │ ├── about.png │ ├── info.png │ ├── main.png │ └── warning.png │ ├── res │ ├── images │ │ ├── close.png │ │ ├── help.png │ │ ├── max.png │ │ ├── min.png │ │ └── normal.png │ ├── main.qrc │ └── main.qss │ └── src │ ├── PublicGUI │ └── FramelessWidget │ │ ├── framelesswidget.cpp │ │ ├── framelesswidget.h │ │ └── framelesswidget.ui │ ├── UI │ ├── About │ │ ├── aboutdlg.cpp │ │ ├── aboutdlg.h │ │ └── aboutdlg.ui │ ├── MainWindow │ │ ├── mainwindow.cpp │ │ ├── mainwindow.h │ │ └── mainwindow.ui │ └── WarningDlg │ │ ├── warningdlg.cpp │ │ ├── warningdlg.h │ │ └── warningdlg.ui │ └── main.cpp └── UI ├── ListView ├── src │ ├── DelegatePainter.cpp │ ├── DelegatePainter.h │ ├── ListView.cpp │ ├── ListView.h │ ├── StyledDelegate.cpp │ └── StyledDelegate.h └── test │ ├── DataDefines.h │ ├── ItemDelegate.cpp │ ├── ItemDelegate.h │ ├── TestView.cpp │ └── TestView.h ├── QGraphicsView ├── QGraphicsViewFramework │ ├── 10 │ │ ├── 10.vcxproj │ │ ├── 10.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── Enemy.cpp │ │ ├── Enemy.h │ │ ├── Game.cpp │ │ ├── Game.h │ │ ├── Tower.cpp │ │ ├── Tower.h │ │ ├── app.qrc │ │ ├── bullet.png │ │ ├── enemy.png │ │ ├── main.cpp │ │ └── tower.png │ ├── 01 │ │ ├── 01.vcxproj │ │ ├── 01.vcxproj.filters │ │ └── main.cpp │ ├── 02 │ │ ├── 02.vcxproj │ │ ├── 02.vcxproj.filters │ │ ├── MyRect.cpp │ │ ├── MyRect.h │ │ └── main.cpp │ ├── 03 │ │ ├── 03.vcxproj │ │ ├── 03.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── MyRect.cpp │ │ ├── MyRect.h │ │ └── main.cpp │ ├── 04 │ │ ├── 04.vcxproj │ │ ├── 04.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── MyRect.cpp │ │ ├── MyRect.h │ │ └── main.cpp │ ├── 05 │ │ ├── 05.vcxproj │ │ ├── 05.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── Enemy.cpp │ │ ├── Enemy.h │ │ ├── MyRect.cpp │ │ ├── MyRect.h │ │ └── main.cpp │ ├── 06 │ │ ├── 06.vcxproj │ │ ├── 06.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── Enemy.cpp │ │ ├── Enemy.h │ │ ├── Game.cpp │ │ ├── Game.h │ │ ├── Health.cpp │ │ ├── Health.h │ │ ├── Player.cpp │ │ ├── Player.h │ │ ├── Score.cpp │ │ ├── Score.h │ │ └── main.cpp │ ├── 07 │ │ ├── 07.vcxproj │ │ ├── 07.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── Enemy.cpp │ │ ├── Enemy.h │ │ ├── Game.cpp │ │ ├── Game.h │ │ ├── Health.cpp │ │ ├── Health.h │ │ ├── Player.cpp │ │ ├── Player.h │ │ ├── Score.cpp │ │ ├── Score.h │ │ └── main.cpp │ ├── 08 │ │ ├── 08.vcxproj │ │ ├── 08.vcxproj.filters │ │ ├── Bullet.cpp │ │ ├── Bullet.h │ │ ├── Enemy.cpp │ │ ├── Enemy.h │ │ ├── Game.cpp │ │ ├── Game.h │ │ ├── Health.cpp │ │ ├── Health.h │ │ ├── Player.cpp │ │ ├── Player.h │ │ ├── Score.cpp │ │ ├── Score.h │ │ ├── app.qrc │ │ ├── bullet.png │ │ ├── main.cpp │ │ ├── player.png │ │ └── tiger.png │ ├── 09 │ │ ├── 09.vcxproj │ │ ├── 09.vcxproj.filters │ │ ├── Game.cpp │ │ ├── Game.h │ │ ├── Tower.cpp │ │ ├── Tower.h │ │ ├── app.qrc │ │ ├── main.cpp │ │ └── tower.png │ └── GraphicsViewFramework.sln └── readme.txt ├── QQFriendList ├── QQFriendList.sln └── QQFriendList │ ├── FriendTree │ ├── FriendTree.cpp │ ├── FriendTree.h │ ├── ItemDelegate.cpp │ └── ItemDelegate.h │ ├── GlobalDefines.h │ ├── PublicGui │ └── TreeView │ │ ├── DelegatePainter.cpp │ │ ├── DelegatePainter.h │ │ ├── StyledDelegate.cpp │ │ ├── StyledDelegate.h │ │ ├── TreeView.cpp │ │ └── TreeView.h │ ├── QQFriendList.qrc │ ├── QQFriendList.vcxproj │ ├── Resources │ └── images │ │ ├── busy-im.svg │ │ ├── expand_down.svg │ │ ├── expand_right.svg │ │ ├── leave-im.svg │ │ ├── online-im.svg │ │ ├── portrait_boy.svg │ │ ├── portrait_girl.svg │ │ ├── video.svg │ │ └── video_hover.svg │ └── main.cpp ├── QTableView └── QTableView │ ├── QTableView.pro │ ├── headerview.cpp │ ├── headerview.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QTableWidget └── QTableWidget.cc ├── Qt控件提升 ├── MyselfWidget.pro ├── main.cpp ├── passwordlineedit.cpp ├── passwordlineedit.h ├── widget.cpp ├── widget.h └── widget.ui ├── Toast ├── Toast.sln └── Toast │ ├── Toast.cpp │ ├── Toast.h │ ├── Toast.qrc │ ├── Toast.ui │ ├── Toast.vcxproj │ └── main.cpp └── 分辨率修改事件 ├── DisplayChangedEventDemo.sln └── DisplayChangedEventDemo ├── DisplayChangedEventDemo.cpp ├── DisplayChangedEventDemo.h ├── DisplayChangedEventDemo.qrc ├── DisplayChangedEventDemo.ui ├── DisplayChangedEventDemo.vcxproj └── main.cpp /Animation/QtAnimation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.421 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtAnimation", "QtAnimation\QtAnimation.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {52D9B18D-0158-4B48-8784-75ED07A86F2E} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Animation/QtAnimation/MainWindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Animation/QtAnimation/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ui/MainWindow/MainWindow.h" 2 | #include 3 | using namespace animation; 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Animation/QtAnimation/ui/MainWindow/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include 3 | #include 4 | 5 | namespace animation 6 | { 7 | MainWindow::MainWindow(QWidget *parent) 8 | : QWidget(parent) 9 | { 10 | ui.setupUi(this); 11 | 12 | initUi(); 13 | initConnection(); 14 | } 15 | 16 | void MainWindow::initUi() 17 | { 18 | setWindowFlags(windowFlags() | Qt::FramelessWindowHint); 19 | } 20 | 21 | void MainWindow::initConnection() 22 | { 23 | connect(ui.pushButton, &QPushButton::clicked, [&] 24 | { 25 | static int resizeValue{100}; 26 | resizeValue = -resizeValue; 27 | QPropertyAnimation* animation = new QPropertyAnimation(this, "geometry"); 28 | animation->setDuration(500); 29 | animation->setStartValue(QRect(pos().x(), pos().y(), width(), height())); 30 | //animation->setEndValue(QRect(pos().x() + resizeValue, pos().y() + resizeValue, width(), height())); 31 | animation->setEndValue(QRect(pos().x() + width(), pos().y(), 0, height())); 32 | animation->setEasingCurve(QEasingCurve::Linear); 33 | animation->start(QAbstractAnimation::DeleteWhenStopped); 34 | }); 35 | 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Animation/QtAnimation/ui/MainWindow/MainWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_MainWindow.h" 5 | 6 | namespace animation 7 | { 8 | class MainWindow : public QWidget 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | MainWindow(QWidget *parent = Q_NULLPTR); 14 | 15 | private: 16 | void initUi(); 17 | void initConnection(); 18 | 19 | private: 20 | Ui::MainWindowClass ui; 21 | }; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Animation/QtAnimation/ui/MainWindow/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindowClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 600 10 | 400 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 130 20 | 70 21 | 75 22 | 23 23 | 24 | 25 | 26 | PushButton 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Core/Excel十进制转为26进制/10to26.pro: -------------------------------------------------------------------------------- 1 | QT += core 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = 10to26 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | -------------------------------------------------------------------------------- /Core/Excel十进制转为26进制/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | QString ConvertFromNumber(int number) 5 | { 6 | QString resultStr = ""; 7 | while(number > 0) 8 | { 9 | int k = number % 26; 10 | if(k == 0) 11 | k = 26; 12 | resultStr.push_front(QChar(k + 64)); 13 | number = (number - k) / 26; 14 | } 15 | 16 | qDebug() << resultStr; 17 | return resultStr; 18 | } 19 | 20 | 21 | 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | QCoreApplication a(argc, argv); 26 | 27 | 28 | ConvertFromNumber(6); 29 | return a.exec(); 30 | } 31 | -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsViewTest", "GraphicsViewTest\GraphicsViewTest.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/GeneratedFiles/qrc_GraphicsViewTest.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Resource object code 3 | ** 4 | ** Created by: The Resource Compiler for Qt version 5.6.2 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #ifdef QT_NAMESPACE 10 | # define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name 11 | # define QT_RCC_MANGLE_NAMESPACE0(x) x 12 | # define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b 13 | # define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) 14 | # define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ 15 | QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) 16 | #else 17 | # define QT_RCC_PREPEND_NAMESPACE(name) name 18 | # define QT_RCC_MANGLE_NAMESPACE(name) name 19 | #endif 20 | 21 | #ifdef QT_NAMESPACE 22 | namespace QT_NAMESPACE { 23 | #endif 24 | 25 | #ifdef QT_NAMESPACE 26 | } 27 | #endif 28 | 29 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_GraphicsViewTest)(); 30 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_GraphicsViewTest)() 31 | { 32 | return 1; 33 | } 34 | 35 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_GraphicsViewTest)(); 36 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_GraphicsViewTest)() 37 | { 38 | return 1; 39 | } 40 | 41 | namespace { 42 | struct initializer { 43 | initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_GraphicsViewTest)(); } 44 | ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_GraphicsViewTest)(); } 45 | } dummy; 46 | } 47 | -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/GraphicsViewTest.cpp: -------------------------------------------------------------------------------- 1 | #include "GraphicsViewTest.h" 2 | #include 3 | float XXX = 1; 4 | GraphicsViewTest::GraphicsViewTest(QDialog *parent) 5 | : QDialog(parent) 6 | { 7 | ui.setupUi(this); 8 | m_scene = new MainScene(this); 9 | ui.bottomGraphicsView->setScene(m_scene); 10 | this->resize(1366, 768); 11 | ui.bottomGraphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 12 | ui.bottomGraphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 13 | ui.bottomGraphicsView->setCursor(Qt::PointingHandCursor); 14 | ui.bottomGraphicsView->setRenderHint(QPainter::Antialiasing); 15 | } 16 | 17 | GraphicsViewTest::~GraphicsViewTest() 18 | { 19 | 20 | } -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/GraphicsViewTest.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GRAPHICSVIEWTEST_H 3 | #define GRAPHICSVIEWTEST_H 4 | 5 | #include 6 | #include 7 | #include "ui_GraphicsViewTest.h" 8 | #include "MainScene.h" 9 | #include 10 | 11 | class GraphicsViewTest : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit GraphicsViewTest(QDialog *parent = 0); 17 | ~GraphicsViewTest(); 18 | 19 | private: 20 | Ui::GraphicsViewTestClass ui; 21 | 22 | MainScene* m_scene; 23 | }; 24 | 25 | #endif // GRAPHICSVIEWTEST_H -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/GraphicsViewTest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/MainScene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/QGraphicsview_test/GraphicsViewTest/MainScene.cpp -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/MainScene.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/QGraphicsview_test/GraphicsViewTest/MainScene.h -------------------------------------------------------------------------------- /Core/QGraphicsview_test/GraphicsViewTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include "GraphicsViewTest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | GraphicsViewTest w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Core/QThreadPool/QThreadPool.pro: -------------------------------------------------------------------------------- 1 | QT += core 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = QThreadPool 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp \ 13 | printtask.cpp 14 | 15 | HEADERS += \ 16 | printtask.h 17 | -------------------------------------------------------------------------------- /Core/QThreadPool/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "printtask.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QCoreApplication a(argc, argv); 8 | 9 | QThreadPool pool; 10 | pool.setMaxThreadCount(3); 11 | 12 | for(int i = 0; i < 20; i++) 13 | { 14 | pool.start(new PrintTask()); 15 | } 16 | 17 | return a.exec(); 18 | } 19 | /* 20 | PrintTask run 被调用,调用线程ID为:00533678 21 | PrintTask run 被调用,调用线程ID为:00533678 22 | PrintTask run 被调用,调用线程ID为:004F3868 23 | PrintTask run 被调用,调用线程ID为:004F3848 24 | PrintTask run 被调用,调用线程ID为:00533678 25 | PrintTask run 被调用,调用线程ID为:00533678 26 | PrintTask run 被调用,调用线程ID为:004F3848 27 | PrintTask run 被调用,调用线程ID为:004F3868 28 | PrintTask run 被调用,调用线程ID为:00533678 29 | PrintTask run 被调用,调用线程ID为:00533678 30 | PrintTask run 被调用,调用线程ID为:004F3848 31 | PrintTask run 被调用,调用线程ID为:00533678 32 | PrintTask run 被调用,调用线程ID为:004F3868 33 | PrintTask run 被调用,调用线程ID为:004F3848 34 | PrintTask run 被调用,调用线程ID为:00533678 35 | PrintTask run 被调用,调用线程ID为:004F3868 36 | PrintTask run 被调用,调用线程ID为:004F3848 37 | PrintTask run 被调用,调用线程ID为:004F3868 38 | ... 39 | */ 40 | -------------------------------------------------------------------------------- /Core/QThreadPool/printtask.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/QThreadPool/printtask.cpp -------------------------------------------------------------------------------- /Core/QThreadPool/printtask.h: -------------------------------------------------------------------------------- 1 | #ifndef PRINTTASK_H 2 | #define PRINTTASK_H 3 | 4 | #include 5 | #include 6 | 7 | class PrintTask : public QObject, public QRunnable 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | PrintTask(); 13 | ~PrintTask(); 14 | protected: 15 | void run(); 16 | 17 | signals: 18 | //注意!要使用信号,采用QObejct 和 QRunnable多继承,记得QObject要放在前面 19 | void mySignal(); 20 | }; 21 | 22 | #endif // PRINTTASK_H 23 | -------------------------------------------------------------------------------- /Core/Qt和C++11thread/ThreadTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/Qt和C++11thread/ThreadTest.cpp -------------------------------------------------------------------------------- /Core/Qt和C++11thread/ThreadTest.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/Qt和C++11thread/ThreadTest.h -------------------------------------------------------------------------------- /Core/Qt和C++11thread/ThreadTest.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ThreadTestClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 505 10 | 178 11 | 12 | 13 | 14 | ThreadTest 15 | 16 | 17 | 18 | 19 | 20 | 21 | 0 22 | 50 23 | 24 | 25 | 26 | test 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Core/StaticCallbackTest/StaticCallBackTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StaticCallBackTest", "StaticCallBackTest\StaticCallBackTest.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 18 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 19 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|Win32 20 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 21 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /Core/StaticCallbackTest/StaticCallBackTest/StaticCallBackTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/StaticCallbackTest/StaticCallBackTest/StaticCallBackTest.cpp -------------------------------------------------------------------------------- /Core/StaticCallbackTest/StaticCallBackTest/StaticCallBackTest.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Core/StaticCallbackTest/StaticCallBackTest/StaticCallBackTest.h -------------------------------------------------------------------------------- /Core/StaticCallbackTest/StaticCallBackTest/StaticCallBackTest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Core/StaticCallbackTest/StaticCallBackTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include "StaticCallBackTest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | StaticCallBackTest w; 8 | w.start(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Core/字符串设置固定宽度,前位补0/字符串设置固定宽度,前位补0.cc: -------------------------------------------------------------------------------- 1 | QString str= QString::number(17); 2 | //10进制数 17 4位 前位补0 strNew = "0017" 3 | QString strNew = QString("%1").arg(str.toInt(), 4, 10, QLatin1Char('0')); 4 | 5 | QString strNew16 = QString("%1").arg(str.toInt(), 4, 16, QLatin1Char('0')); -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppTranslation", "AppTranslation\AppTranslation.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/MainWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/AppTranslation/AppTranslation/MainWindow.cpp -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/MainWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_MainWindow.h" 5 | 6 | #include "TranslationSupport.h" 7 | 8 | class MainWindow : public QWidget, public TranslationSupport 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | MainWindow(QWidget *parent = Q_NULLPTR); 14 | 15 | public: 16 | virtual void retranslate(); 17 | private: 18 | Ui::MainWindowClass ui; 19 | }; 20 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindowClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 267 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | Change 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/TranslationSupport.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/AppTranslation/AppTranslation/TranslationSupport.h -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget1.cpp: -------------------------------------------------------------------------------- 1 | #include "Widget1.h" 2 | #include "ui_Widget1.h" 3 | 4 | Widget1::Widget1(QWidget *parent) 5 | : QWidget(parent) 6 | { 7 | ui = new Ui::Widget1(); 8 | ui->setupUi(this); 9 | 10 | setFixedSize(300, 200); 11 | } 12 | 13 | Widget1::~Widget1() 14 | { 15 | delete ui; 16 | } 17 | 18 | void Widget1::retranslate() 19 | { 20 | ui->retranslateUi(this); 21 | } 22 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "TranslationSupport.h" 5 | 6 | namespace Ui { class Widget1; }; 7 | 8 | class Widget1 : public QWidget, public TranslationSupport 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | Widget1(QWidget *parent = Q_NULLPTR); 14 | ~Widget1(); 15 | 16 | public: 17 | virtual void retranslate(); 18 | 19 | private: 20 | Ui::Widget1 *ui; 21 | }; 22 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget1.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget1 4 | 5 | 6 | 7 | 0 8 | 0 9 | 535 10 | 391 11 | 12 | 13 | 14 | Widget1 15 | 16 | 17 | 18 | 19 | 20 | welldone 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget2.cpp: -------------------------------------------------------------------------------- 1 | #include "Widget2.h" 2 | #include "ui_Widget2.h" 3 | 4 | Widget2::Widget2(QWidget *parent) 5 | : QWidget(parent) 6 | { 7 | ui = new Ui::Widget2(); 8 | ui->setupUi(this); 9 | 10 | setFixedSize(300, 200); 11 | } 12 | 13 | Widget2::~Widget2() 14 | { 15 | delete ui; 16 | } 17 | 18 | void Widget2::retranslate() 19 | { 20 | ui->retranslateUi(this); 21 | } 22 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "TranslationSupport.h" 5 | 6 | namespace Ui { class Widget2; }; 7 | 8 | class Widget2 : public QWidget, public TranslationSupport 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | Widget2(QWidget *parent = Q_NULLPTR); 14 | ~Widget2(); 15 | 16 | public: 17 | virtual void retranslate(); 18 | 19 | private: 20 | Ui::Widget2 *ui; 21 | }; 22 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/Widget2.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget2 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Widget2 15 | 16 | 17 | 18 | 19 | 20 | china 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/apptranslation_en.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/AppTranslation/AppTranslation/apptranslation_en.qm -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/apptranslation_en.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | MainWindow 9 | It is App Main Window 10 | 11 | 12 | 13 | Change 14 | change language 15 | 16 | 17 | 18 | Widget1 19 | 20 | 21 | Widget1 22 | it is widget 1 23 | 24 | 25 | 26 | welldone 27 | Well Done ! 28 | 29 | 30 | 31 | Widget2 32 | 33 | 34 | Widget2 35 | it is widget 2 36 | 37 | 38 | 39 | china 40 | China! 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/apptranslation_zh.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/AppTranslation/AppTranslation/apptranslation_zh.qm -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/apptranslation_zh.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MainWindowClass 6 | 7 | 8 | MainWindow 9 | 主窗口 10 | 11 | 12 | 13 | Change 14 | 换语言 15 | 16 | 17 | 18 | Widget1 19 | 20 | 21 | Widget1 22 | 窗口1 23 | 24 | 25 | 26 | welldone 27 | 干得漂亮! 28 | 29 | 30 | 31 | Widget2 32 | 33 | 34 | Widget2 35 | 窗口2 36 | 37 | 38 | 39 | china 40 | 中华人民共和国 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Project/AppTranslation/AppTranslation/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainWindow.h" 3 | 4 | #include "Widget1.h" 5 | #include "Widget2.h" 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | 12 | 13 | Widget1 w1; 14 | Widget2 w2; 15 | 16 | w1.show(); 17 | w2.show(); 18 | 19 | MainWindow w; 20 | w.show(); 21 | 22 | 23 | return a.exec(); 24 | } 25 | -------------------------------------------------------------------------------- /Project/AppTranslation/gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/AppTranslation/gif.gif -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DrawCircleAngleWindow", "DrawCircleAngleWindow\DrawCircleAngleWindow.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.cpp -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.h -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow/MyWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | MyWindowClass 3 | 4 | 5 | MyWindowClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | MyWindow 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Project/DrawCircleAngleWindow/DrawCircleAngleWindow/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MyWindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MyWindow w; 8 | //w.setType(LeftTop); 9 | //w.setType(RightTop); 10 | //w.setType(LeftBottom); 11 | //w.setType(RightBottom); 12 | //w.setType(Top); 13 | //w.setType(Bottom); 14 | //w.setType(Left); 15 | //w.setType(Right); 16 | //w.setType(All); 17 | 18 | w.show(); 19 | return a.exec(); 20 | } 21 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QRCodeDemo", "QRCodeDemo\QRCodeDemo.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/QRCodeDemo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QRCodeDemo/QRCodeDemo/QRCodeDemo.cpp -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/QRCodeDemo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_QRCodeDemo.h" 5 | 6 | class QRCodeDemo : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | QRCodeDemo(QWidget *parent = Q_NULLPTR); 12 | 13 | public: 14 | void setCodeString(const QString& strCodeString); 15 | 16 | protected: 17 | virtual void paintEvent(QPaintEvent *event); 18 | 19 | private: 20 | Ui::QRCodeDemoClass ui; 21 | 22 | QString m_strCodeString; 23 | }; 24 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/QRCodeDemo.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "QRCodeDemo.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | QRCodeDemo w; 8 | w.setCodeString("https://blog.csdn.net/y396397735"); 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/qrcode/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __BITSTREAM_H__ 23 | #define __BITSTREAM_H__ 24 | 25 | typedef struct { 26 | int length; 27 | unsigned char *data; 28 | } BitStream; 29 | 30 | extern BitStream *BitStream_new(void); 31 | extern int BitStream_append(BitStream *bstream, BitStream *arg); 32 | extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); 33 | extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); 34 | #define BitStream_size(__bstream__) (__bstream__->length) 35 | extern unsigned char *BitStream_toByte(BitStream *bstream); 36 | extern void BitStream_free(BitStream *bstream); 37 | 38 | #endif /* __BITSTREAM_H__ */ 39 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/qrcode/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | // manual config.h for microsoft visual studio 5 | 6 | #define HAVE_STRDUP 1 7 | 8 | #define static static 9 | 10 | #define MAJOR_VERSION 1 11 | #define MINOR_VERSION 0 12 | #define MICRO_VERSION 0 13 | #define VERSION "" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/qrcode/mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MASK_H__ 23 | #define __MASK_H__ 24 | 25 | extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int Mask_calcN2(int width, unsigned char *frame); 30 | extern int Mask_calcN1N3(int length, int *runLength); 31 | extern int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength); 32 | extern int Mask_evaluateSymbol(int width, unsigned char *frame); 33 | extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); 34 | extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); 35 | #endif 36 | 37 | #endif /* __MASK_H__ */ 38 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/qrcode/mmask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking for Micro QR Code. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MMASK_H__ 23 | #define __MMASK_H__ 24 | 25 | extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int MMask_evaluateSymbol(int width, unsigned char *frame); 30 | extern void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level); 31 | extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); 32 | #endif 33 | 34 | #endif /* __MMASK_H__ */ 35 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/QRCodeDemo/qrcode/rscode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon encoder. This code is taken from Phil Karn's libfec then 5 | * editted and packed into a pair of .c and .h files. 6 | * 7 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 8 | * (libfec is released under the GNU Lesser General Public License.) 9 | * 10 | * Copyright (C) 2006-2011 Kentaro Fukuchi 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #ifndef __RSCODE_H__ 28 | #define __RSCODE_H__ 29 | 30 | /* 31 | * General purpose RS codec, 8-bit symbols. 32 | */ 33 | 34 | typedef struct _RS RS; 35 | 36 | extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); 37 | extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); 38 | extern void free_rs_char(RS *rs); 39 | extern void free_rs_cache(void); 40 | 41 | #endif /* __RSCODE_H__ */ 42 | -------------------------------------------------------------------------------- /Project/QRCodeDemo/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QRCodeDemo/result.png -------------------------------------------------------------------------------- /Project/QmlUseCppModel/QmlUseCppModel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QmlUseCppModel", "QmlUseCppModel\QmlUseCppModel.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/QmlUseCppModel/QmlUseCppModel/CustomModel.cpp: -------------------------------------------------------------------------------- 1 | #include "CustomModel.h" 2 | 3 | CustomModel::CustomModel(QObject *parent) 4 | : QAbstractListModel(parent) 5 | { 6 | } 7 | 8 | CustomModel::~CustomModel() 9 | { 10 | } 11 | 12 | int CustomModel::rowCount(const QModelIndex &parent /*= QModelIndex()*/) const 13 | { 14 | Q_UNUSED(parent); 15 | return m_studentList.count(); 16 | } 17 | 18 | QVariant CustomModel::data(const QModelIndex &index, int role /*= Qt::DisplayRole*/) const 19 | { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Project/QmlUseCppModel/QmlUseCppModel/CustomModel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QmlUseCppModel/QmlUseCppModel/CustomModel.h -------------------------------------------------------------------------------- /Project/QmlUseCppModel/QmlUseCppModel/QmlUseCppModel.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/QmlUseCppModel/QmlUseCppModel/main.cpp: -------------------------------------------------------------------------------- 1 | #include "QmlUseCppModel.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | QmlUseCppModel w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Project/QtAppCallQml/QtAppCallQml.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtAppCallQml", "QtAppCallQml\QtAppCallQml.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | Qt5Version = 5.9.6 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Project/QtAppCallQml/QtAppCallQml/QtAppCallQml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/main.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project/QtAppCallQml/QtAppCallQml/Resources/main.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.7 2 | import QtQuick.Controls 2.2 3 | 4 | Rectangle { 5 | id:root; 6 | width: 800; 7 | height: 600; 8 | SwipeView { 9 | id:swipeView; 10 | objectName:"swipeViewObj"; 11 | anchors.fill: parent; 12 | Rectangle { 13 | id:page1; 14 | objectName: "page1Obj"; 15 | color: "red"; 16 | 17 | function setColor(c){ 18 | color = c; 19 | } 20 | } 21 | Rectangle { 22 | color: "green"; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Project/QtAppCallQml/QtAppCallQml/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtAppCallQml/QtAppCallQml/main.cpp -------------------------------------------------------------------------------- /Project/QtFormDataDemo/QtFormDataDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtFormDataDemo", "QtFormDataDemo.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/QtFormDataDemo/QtFormDataDemo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 14 | qrc;* 15 | false 16 | 17 | 18 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 19 | qrc;* 20 | false 21 | 22 | 23 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 24 | moc;h;cpp 25 | False 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /Project/QtFormDataDemo/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtFormDataDemo/main.cpp -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/CallBackTest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/MainWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/CallBackTest/MainWindow.cpp -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/MainWindow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/CallBackTest/MainWindow.h -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/Square.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/CallBackTest/Square.cpp -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/Square.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/CallBackTest/Square.h -------------------------------------------------------------------------------- /Project/QtGuiApplication/CallBackTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest/SingleAppTest.cpp: -------------------------------------------------------------------------------- 1 | #include "SingleAppTest.h" 2 | 3 | SingleAppTest::SingleAppTest(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | ui.setupUi(this); 7 | } 8 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest/SingleAppTest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_SingleAppTest.h" 5 | 6 | class SingleAppTest : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | SingleAppTest(QWidget *parent = Q_NULLPTR); 12 | 13 | private: 14 | Ui::SingleAppTestClass ui; 15 | }; 16 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest/SingleAppTest.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest/SingleAppTest.ui: -------------------------------------------------------------------------------- 1 | 2 | SingleAppTestClass 3 | 4 | 5 | SingleAppTestClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | SingleAppTest 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/SingleAppTest/main.cpp -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest2/SingleAppTest2.cpp: -------------------------------------------------------------------------------- 1 | #include "SingleAppTest2.h" 2 | 3 | SingleAppTest2::SingleAppTest2(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | ui.setupUi(this); 7 | } 8 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest2/SingleAppTest2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "ui_SingleAppTest2.h" 5 | 6 | class SingleAppTest2 : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | SingleAppTest2(QWidget *parent = Q_NULLPTR); 12 | 13 | private: 14 | Ui::SingleAppTest2Class ui; 15 | }; 16 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest2/SingleAppTest2.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest2/SingleAppTest2.ui: -------------------------------------------------------------------------------- 1 | 2 | SingleAppTest2Class 3 | 4 | 5 | SingleAppTest2Class 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | SingleAppTest2 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Project/QtGuiApplication/SingleAppTest2/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/QtGuiApplication/SingleAppTest2/main.cpp -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VSQtUseQmlUi", "VSQtUseQmlUi\VSQtUseQmlUi.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi/App.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | SwipeViewQml.qml 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi/SwipeViewQml.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.9 2 | import QtQuick.Controls 2.2 3 | 4 | Rectangle { 5 | width : 800; 6 | height : 600; 7 | SwipeView { 8 | objectName: "swipeView"; 9 | anchors.fill : parent; 10 | signal signalPageChanged(int index); 11 | onCurrentIndexChanged: signalPageChanged(currentIndex); 12 | Rectangle { 13 | id:redRect; 14 | objectName:"redPage"; 15 | color:"red"; 16 | signal signalClicked(string objName); // redPage对象内部自定义信号 17 | 18 | // 内部方法设置颜色 19 | function setTheColor(newColor){ 20 | color = newColor; 21 | } 22 | 23 | MouseArea { 24 | anchors.fill:parent; 25 | onClicked:redRect.signalClicked(redRect.objectName); 26 | } 27 | } 28 | Rectangle { 29 | id:greenRect; 30 | objectName:"greenPage"; 31 | color:"green"; 32 | signal signalClicked(string objName); // greenPage对象内部自定义信号 33 | MouseArea { 34 | anchors.fill:parent; 35 | onClicked:greenRect.signalClicked(greenRect.objectName); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi/Window.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/VSQtUseQmlUi/VSQtUseQmlUi/Window.cpp -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi/Window.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/VSQtUseQmlUi/VSQtUseQmlUi/Window.h -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/VSQtUseQmlUi/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Window.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Window w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Project/VSQtUseQmlUi/效果.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/VSQtUseQmlUi/效果.gif -------------------------------------------------------------------------------- /Project/WebTest/WebTest.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebTest", "WebTest\WebTest.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | Qt5Version = 5.9.6 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Project/WebTest/WebTest/BMap.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | Web测试 12 | 13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /Project/WebTest/WebTest/WebTest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Project/WebTest/WebTest/WebTest.cpp -------------------------------------------------------------------------------- /Project/WebTest/WebTest/WebTest.h: -------------------------------------------------------------------------------- 1 | /** @file WebTest.h 2 | * @note 3 | * 4 | * @brief Qt 使用web引擎开发Demo 5 | * @author lesliefish 6 | * @date 2018/11/30 7 | */ 8 | #pragma once 9 | 10 | #include 11 | #include 12 | #include 13 | #include "ui_WebTest.h" 14 | 15 | class WebTest : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | WebTest(QWidget *parent = Q_NULLPTR); 21 | 22 | private: 23 | void initUi(); 24 | void initConncetion(); 25 | // 加载html文件 26 | void loadHtml(); 27 | // 获取js函数返回值 28 | QString getJsRetString(); 29 | 30 | public slots: 31 | void recieveJsMessage(const QString& jsMsg); 32 | 33 | private: 34 | Ui::WebTestClass ui; 35 | 36 | QWebEngineView *m_pWebView{ nullptr }; 37 | QWebChannel* m_pWebChannel{ nullptr }; 38 | }; 39 | -------------------------------------------------------------------------------- /Project/WebTest/WebTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include "WebTest.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | WebTest w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /PyQt/Python_CAD/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | from pyautocad import Autocad, APoint 3 | 4 | acad = Autocad(create_if_not_exists = True) 5 | p = APoint(500, 500) 6 | 7 | def recur(p, step, layer): 8 | if layer == 10: 9 | return 10 | p2 = next_p(p, layer, step) 11 | acad.model.AddLine(p, p2) 12 | layer += 1 13 | step += 5 14 | print(step) 15 | recur(p2, step, layer) 16 | 17 | def next_p(p, i, step): 18 | x = p.x 19 | y = p.y 20 | if i % 4 == 0: 21 | x += step 22 | elif i % 4 == 1: 23 | y += step 24 | elif i % 4 == 2: 25 | x -= step 26 | elif i % 4 == 3: 27 | y -= step 28 | return APoint(x, y) 29 | 30 | def print_obj_name(): 31 | for obj in acad.iter_objects(): 32 | print (obj.ObjectName) 33 | 34 | if __name__ == '__main__': 35 | recur(p, 0, 0) 36 | print_obj_name() 37 | -------------------------------------------------------------------------------- /PyQt/README.MD: -------------------------------------------------------------------------------- 1 | Qt界面 与 Python 的融合 2 | -------------------------------------------------------------------------------- /PyQt/Tools/CAD操作手册acadauto.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/PyQt/Tools/CAD操作手册acadauto.chm -------------------------------------------------------------------------------- /QSS/QCheckBox.qss: -------------------------------------------------------------------------------- 1 | QCheckBox 2 | { 3 | color:#222222; 4 | font-size: 12px; 5 | font-family:microsoft yahei; 6 | } 7 | 8 | QCheckBox::indicator { 9 | width: 17px; 10 | height: 17px; 11 | image:url(:/UI/images/CheckBox/checkbox_nor.png); 12 | } 13 | QCheckBox::indicator:enabled:unchecked { 14 | image:url(:/UI/images/CheckBox/checkbox_nor.png); 15 | } 16 | QCheckBox::indicator:enabled:unchecked:pressed { 17 | image:url(:/UI/images/CheckBox/checkbox_nor.png); 18 | } 19 | QCheckBox::indicator:enabled:unchecked:hover { 20 | image: url(:/UI/images/CheckBox/checkbox_hover.png); 21 | } 22 | 23 | QCheckBox::indicator:enabled:checked { 24 | image: url(:/UI/images/CheckBox/checkboxon_hover.png); 25 | } 26 | QCheckBox::indicator:enabled:checked:hover { 27 | image: url(:/UI/images/CheckBox/checkboxon_hover.png); 28 | } 29 | QCheckBox::indicator:enabled:checked:pressed { 30 | image: url(:/UI/images/CheckBox/checkbox_hover.png); 31 | } 32 | QCheckBox::indicator:enabled:indeterminate { 33 | image: url(:/UI/images/CheckBox/halfcheckbox_hover.png); 34 | } 35 | QCheckBox::indicator:enabled:indeterminate:hover { 36 | image: url(:/UI/images/CheckBox/halfcheckbox_hover.png); 37 | } 38 | QCheckBox::indicator:enabled:indeterminate:pressed { 39 | image: url(:/UI/images/CheckBox/halfcheckbox_hover.png); 40 | } -------------------------------------------------------------------------------- /QSS/QPushButton.qss: -------------------------------------------------------------------------------- 1 | QPushButton 2 | { 3 | color:white; 4 | background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c); 5 | border-width: 1px; 6 | border-color: #339; 7 | border-style: solid; 8 | border-radius: 7; 9 | padding: 3px; 10 | font-size: 10px; 11 | padding-left: 5px; 12 | padding-right: 5px; 13 | min-width: 50px; 14 | max-width: 50px; 15 | min-height: 13px; 16 | max-height: 13px; 17 | } -------------------------------------------------------------------------------- /QSS/QPushButtonQss/QPushButtonQss.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-10-19T13:53:04 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QPushButtonQss 12 | TEMPLATE = app 13 | 14 | 15 | SOURCES += main.cpp\ 16 | dialog.cpp 17 | 18 | HEADERS += dialog.h 19 | 20 | FORMS += dialog.ui 21 | -------------------------------------------------------------------------------- /QSS/QPushButtonQss/button.qss: -------------------------------------------------------------------------------- 1 | QPushButton 2 | { 3 | color:white; 4 | background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c); 5 | border-width: 1px; 6 | border-color: #339; 7 | border-style: solid; 8 | border-radius: 7; 9 | padding: 3px; 10 | font-size: 14px; 11 | padding-left: 5px; 12 | padding-right: 5px; 13 | min-width: 61px; 14 | max-width: 61px; 15 | min-height: 39px; 16 | max-height: 39px; 17 | } -------------------------------------------------------------------------------- /QSS/QPushButtonQss/dialog.cpp: -------------------------------------------------------------------------------- 1 | #include "dialog.h" 2 | #include "ui_dialog.h" 3 | #include 4 | #include 5 | 6 | Dialog::Dialog(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::Dialog) 9 | { 10 | ui->setupUi(this); 11 | 12 | //加载Style 13 | QString path = QDir::currentPath() + "/../QPushButtonQss/button.qss"; 14 | QFile qssFile(path); 15 | qssFile.open(QFile::ReadOnly); 16 | qApp->setStyleSheet(qssFile.readAll()); 17 | qssFile.close(); 18 | } 19 | 20 | Dialog::~Dialog() 21 | { 22 | delete ui; 23 | } 24 | -------------------------------------------------------------------------------- /QSS/QPushButtonQss/dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOG_H 2 | #define DIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Dialog; 8 | } 9 | 10 | class Dialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Dialog(QWidget *parent = 0); 16 | ~Dialog(); 17 | 18 | private: 19 | Ui::Dialog *ui; 20 | }; 21 | 22 | #endif // DIALOG_H 23 | -------------------------------------------------------------------------------- /QSS/QPushButtonQss/dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 554 10 | 225 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 100 20 | 60 21 | 62 22 | 21 23 | 24 | 25 | 26 | 27 | 28 | 29 | 未来之歌 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /QSS/QPushButtonQss/main.cpp: -------------------------------------------------------------------------------- 1 | #include "dialog.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Dialog w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QSS/QScrollBar.qss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/QSS/QScrollBar.qss -------------------------------------------------------------------------------- /QtExcel/ExcelManger.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCELMANGER_H 2 | #define EXCELMANGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class ExcelManger : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit ExcelManger(QObject *parent = 0); 13 | 14 | bool Test(QString& path); 15 | signals: 16 | 17 | public slots: 18 | }; 19 | 20 | #endif // EXCELMANGER_H 21 | -------------------------------------------------------------------------------- /QtExcel/QtExcel.pro: -------------------------------------------------------------------------------- 1 | QT += core axcontainer 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = QtExcel 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp \ 13 | ExcelManger.cpp 14 | 15 | HEADERS += \ 16 | ExcelManger.h 17 | -------------------------------------------------------------------------------- /QtExcel/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "ExcelManger.h" 6 | int main(int argc, char *argv[]) 7 | { 8 | QCoreApplication a(argc, argv); 9 | QString strPath = QDir::currentPath() + "/test.xlsx"; 10 | QFile file(strPath); 11 | if(!file.exists()) 12 | { 13 | qDebug() << "文件不存在"; 14 | return a.exec(); 15 | } 16 | else 17 | { 18 | //文件类型粗略检查 19 | if(!strPath.right(4).contains("xls")) 20 | { 21 | qDebug() << "只操作xlsx、xls文件"; 22 | return a.exec(); 23 | } 24 | } 25 | 26 | ExcelManger em; 27 | em.Test(strPath); 28 | 29 | return a.exec(); 30 | } 31 | -------------------------------------------------------------------------------- /QtExcel/test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/QtExcel/test.xlsx -------------------------------------------------------------------------------- /QtExcel/副本test.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/QtExcel/副本test.xlsx -------------------------------------------------------------------------------- /QtSQL/README: -------------------------------------------------------------------------------- 1 | SQL知识点合集 2 | -------------------------------------------------------------------------------- /QtSQL/SqlTest/SqlTest.pro: -------------------------------------------------------------------------------- 1 | QT += core sql 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = SqlTest 7 | CONFIG += console 8 | CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | -------------------------------------------------------------------------------- /QtSQL/SqlTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | QCoreApplication a(argc, argv); 6 | 7 | return a.exec(); 8 | } 9 | -------------------------------------------------------------------------------- /QtSQL/SqliteReader/SqliteReader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/QtSQL/SqliteReader/SqliteReader.cpp -------------------------------------------------------------------------------- /QtSQL/SqliteReader/SqliteReader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/QtSQL/SqliteReader/SqliteReader.h -------------------------------------------------------------------------------- /QtSQL/SqliteReader/SqliteReader.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SqliteReader", "SqliteReader.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /QtSQL/SqliteReader/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SqliteReader.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QCoreApplication a(argc, argv); 7 | 8 | auto info = SqliteReader::read("mytest.db"); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Qt 2 |   自己学习使用过程中遇到的Qt相关知识汇总,代码上传,总结 3 | 4 | ## Core 5 |   Qt核心组件相关的知识点笔记 6 | 7 | ## Qss 8 |   控件Qss样式表设计 9 | 10 | ## UI 11 |   主要是QtWidgets界面控件相关知识点 12 | 13 | ## QSql 14 |   Qt的数据库操作 15 | 16 | ## Tools 17 |   Qt 编写的工具,库等 18 | -------------------------------------------------------------------------------- /Tools/QtEmail/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.o 3 | *.exe 4 | *.stash 5 | *.user 6 | *.Debug 7 | *.Release 8 | Makefile 9 | Email.pro.user 10 | debug/moc_emailaddress.cpp 11 | debug/moc_mimeattachment.cpp 12 | debug/moc_mimefile.cpp 13 | debug/moc_mimemultipart.cpp 14 | debug/moc_mimepart.cpp 15 | debug/moc_predefs.h 16 | debug/moc_mimehtml.cpp 17 | debug/moc_quotedprintable.cpp 18 | debug/moc_smtpclient.cpp 19 | debug/moc_mimecontentformatter.cpp 20 | -------------------------------------------------------------------------------- /Tools/QtEmail/Email.pro: -------------------------------------------------------------------------------- 1 | QT += core network 2 | QT -= gui 3 | 4 | CONFIG += c++11 5 | 6 | TARGET = Email 7 | CONFIG += console 8 | #CONFIG -= app_bundle 9 | 10 | TEMPLATE = app 11 | 12 | SOURCES += main.cpp \ 13 | src/mimeattachment.cpp \ 14 | src/mimecontentformatter.cpp \ 15 | src/mimefile.cpp \ 16 | src/mimehtml.cpp \ 17 | src/mimeinlinefile.cpp \ 18 | src/mimemessage.cpp \ 19 | src/mimemultipart.cpp \ 20 | src/mimepart.cpp \ 21 | src/mimetext.cpp \ 22 | src/quotedprintable.cpp \ 23 | src/smtpclient.cpp 24 | 25 | DEFINES += QT_DEPRECATED_WARNINGS 26 | 27 | HEADERS += \ 28 | src/mimeattachment.h \ 29 | src/mimecontentformatter.h \ 30 | src/mimefile.h \ 31 | src/mimehtml.h \ 32 | src/mimeinlinefile.h \ 33 | src/mimemessage.h \ 34 | src/mimemultipart.h \ 35 | src/mimepart.h \ 36 | src/mimetext.h \ 37 | src/publicdefine.h \ 38 | src/quotedprintable.h \ 39 | src/smtpclient.h 40 | -------------------------------------------------------------------------------- /Tools/QtEmail/README.md: -------------------------------------------------------------------------------- 1 | Qt 写的一个smtp邮件库,一位俄罗斯大神写的,稍作修改,未完待续.. 2 | -------------------------------------------------------------------------------- /Tools/QtEmail/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "src/publicdefine.h" 3 | #include "src/smtpclient.h" 4 | #include "src/mimetext.h" 5 | #include "src/mimeattachment.h" 6 | using namespace PublicDefine; 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | QCoreApplication a(argc, argv); 11 | SmtpParams smtpParams; 12 | smtpParams.strHost = "smtp.csu.edu.cn"; 13 | smtpParams.iPort = 25; 14 | smtpParams.enumConnectionType = TcpConnection; 15 | smtpParams.enumAuthMethod = AuthLogin; 16 | smtpParams.strUserName = "144712065"; 17 | smtpParams.strPassword = "xxxx"; 18 | smtpParams.iConnectionTimeout = 10000; 19 | smtpParams.iResponseTimeout = 10000; 20 | smtpParams.iSendMessageTimeout = 10000; 21 | 22 | SmtpClient sc(smtpParams); 23 | 24 | MimeMessage message; 25 | EmailAddress sender; 26 | sender.strAddr = "144712065@csu.edu.cn"; 27 | sender.strName = "144712065"; 28 | message.setSender(sender); 29 | 30 | EmailAddress to; 31 | to.strAddr = "44865959@qq.com"; 32 | to.strName = "44865959"; 33 | message.addRecipient(to); 34 | message.setSubject("邮件主题"); 35 | 36 | MimeText text; 37 | text.setText("邮件文本信息.\n"); 38 | message.addPart(&text); 39 | 40 | MimeAttachment attach(new QFile("C:/1.jpg")); 41 | message.addPart(&attach); 42 | 43 | if (!sc.ConnectToHost()) 44 | { 45 | qDebug() << "连接服务器失败!" << endl; 46 | return -1; 47 | } 48 | 49 | if (!sc.Login()) 50 | { 51 | qDebug() << "登录失败!" << endl; 52 | return -2; 53 | } 54 | 55 | if (!sc.SendMail(message)) 56 | { 57 | qDebug() << "发送邮件失败!" << endl; 58 | return -3; 59 | } 60 | 61 | sc.Quit(); 62 | qDebug() << "sent." ; 63 | return a.exec(); 64 | } 65 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimeattachment.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #include "mimeattachment.h" 20 | #include 21 | 22 | /* [1] Constructors and Destructors */ 23 | 24 | MimeAttachment::MimeAttachment(QFile *file) 25 | : MimeFile(file) 26 | { 27 | } 28 | MimeAttachment::MimeAttachment(const QByteArray& stream, const QString& fileName): MimeFile(stream, fileName) 29 | { 30 | 31 | } 32 | 33 | MimeAttachment::~MimeAttachment() 34 | { 35 | } 36 | 37 | /* [1] --- */ 38 | 39 | 40 | /* [2] Protected methods */ 41 | 42 | void MimeAttachment::prepare() 43 | { 44 | this->header += "Content-disposition: attachment\r\n"; 45 | 46 | /* !!! IMPORTANT !!! */ 47 | MimeFile::prepare(); 48 | } 49 | 50 | /* [2] --- */ 51 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimeattachment.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMEATTACHMENT_H 20 | #define MIMEATTACHMENT_H 21 | 22 | #include 23 | #include "mimepart.h" 24 | #include "mimefile.h" 25 | 26 | #include "publicdefine.h" 27 | 28 | class MimeAttachment : public MimeFile 29 | { 30 | Q_OBJECT 31 | public: 32 | 33 | /* [1] Constructors and Destructors */ 34 | 35 | MimeAttachment(QFile* file); 36 | MimeAttachment(const QByteArray& stream, const QString& fileName); 37 | 38 | ~MimeAttachment(); 39 | 40 | /* [1] --- */ 41 | 42 | protected: 43 | 44 | /* [2] Protected methods */ 45 | 46 | virtual void prepare(); 47 | 48 | /* [2] --- */ 49 | }; 50 | 51 | #endif // MIMEATTACHMENT_H 52 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimecontentformatter.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMECONTENTFORMATTER_H 20 | #define MIMECONTENTFORMATTER_H 21 | 22 | #include 23 | #include 24 | 25 | #include "publicdefine.h" 26 | 27 | class MimeContentFormatter : public QObject 28 | { 29 | Q_OBJECT 30 | public: 31 | MimeContentFormatter (int max_length = 76); 32 | 33 | void setMaxLength(int l); 34 | int getMaxLength() const; 35 | 36 | QString format(const QString &content, bool quotedPrintable = false) const; 37 | 38 | protected: 39 | int max_length; 40 | 41 | }; 42 | 43 | #endif // MIMECONTENTFORMATTER_H 44 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimefile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #include "mimefile.h" 20 | #include 21 | 22 | /* [1] Constructors and Destructors */ 23 | 24 | MimeFile::MimeFile(QFile *file) 25 | { 26 | this->file = file; 27 | this->cType = "application/octet-stream"; 28 | this->cName = QFileInfo(*file).fileName(); 29 | this->cEncoding = Base64; 30 | } 31 | 32 | MimeFile::MimeFile(const QByteArray& stream, const QString& fileName) 33 | { 34 | this->cEncoding = Base64; 35 | this->cType = "application/octet-stream"; 36 | this->file = 0; 37 | this->cName = fileName; 38 | this->content = stream; 39 | } 40 | 41 | MimeFile::~MimeFile() 42 | { 43 | if (file) 44 | delete file; 45 | } 46 | 47 | /* [1] --- */ 48 | 49 | 50 | /* [2] Getters and setters */ 51 | 52 | /* [2] --- */ 53 | 54 | 55 | /* [3] Protected methods */ 56 | 57 | void MimeFile::prepare() 58 | { 59 | if (this->file) 60 | { 61 | file->open(QIODevice::ReadOnly); 62 | this->content = file->readAll(); 63 | file->close(); 64 | } 65 | /* !!! IMPORTANT !!!! */ 66 | MimePart::prepare(); 67 | } 68 | 69 | /* [3] --- */ 70 | 71 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimefile.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMEFILE_H 20 | #define MIMEFILE_H 21 | 22 | #include "mimepart.h" 23 | #include 24 | 25 | #include "publicdefine.h" 26 | 27 | class MimeFile : public MimePart 28 | { 29 | Q_OBJECT 30 | public: 31 | 32 | /* [1] Constructors and Destructors */ 33 | 34 | MimeFile(const QByteArray& stream, const QString& fileName); 35 | MimeFile(QFile *f); 36 | ~MimeFile(); 37 | 38 | /* [1] --- */ 39 | 40 | 41 | /* [2] Getters and Setters */ 42 | 43 | /* [2] --- */ 44 | 45 | protected: 46 | 47 | /* [3] Protected members */ 48 | 49 | QFile* file; 50 | 51 | /* [3] --- */ 52 | 53 | 54 | /* [4] Protected methods */ 55 | 56 | virtual void prepare(); 57 | 58 | /* [4] --- */ 59 | 60 | }; 61 | 62 | #endif // MIMEFILE_H 63 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimehtml.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #include "mimehtml.h" 20 | 21 | /* [1] Constructors and Destructors */ 22 | 23 | MimeHtml::MimeHtml(const QString &html) : MimeText(html) 24 | { 25 | this->cType = "text/html"; 26 | } 27 | 28 | MimeHtml::~MimeHtml() {} 29 | 30 | /* [1] --- */ 31 | 32 | 33 | /* [2] Getters and Setters */ 34 | 35 | void MimeHtml::setHtml(const QString & html) 36 | { 37 | this->text = html; 38 | } 39 | 40 | const QString & MimeHtml::getHtml() const 41 | { 42 | return text; 43 | } 44 | 45 | 46 | /* [2] --- */ 47 | 48 | 49 | /* [3] Protected methods */ 50 | 51 | void MimeHtml::prepare() 52 | { 53 | /* !!! IMPORTANT !!! */ 54 | MimeText::prepare(); 55 | } 56 | 57 | /* [3] --- */ 58 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimehtml.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMEHTML_H 20 | #define MIMEHTML_H 21 | 22 | #include "mimetext.h" 23 | 24 | #include "publicdefine.h" 25 | 26 | class MimeHtml : public MimeText 27 | { 28 | Q_OBJECT 29 | public: 30 | 31 | /* [1] Constructors and Destructors */ 32 | 33 | MimeHtml(const QString &html = ""); 34 | ~MimeHtml(); 35 | 36 | /* [1] --- */ 37 | 38 | 39 | /* [2] Getters and Setters */ 40 | 41 | void setHtml(const QString & html); 42 | 43 | const QString& getHtml() const; 44 | 45 | /* [2] --- */ 46 | 47 | protected: 48 | 49 | /* [3] Protected members */ 50 | 51 | /* [3] --- */ 52 | 53 | 54 | /* [4] Protected methods */ 55 | 56 | virtual void prepare(); 57 | 58 | /* [4] --- */ 59 | }; 60 | 61 | #endif // MIMEHTML_H 62 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimeinlinefile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #include "mimeinlinefile.h" 20 | 21 | /* [1] Constructors and Destructors */ 22 | 23 | MimeInlineFile::MimeInlineFile(QFile *f) 24 | : MimeFile(f) 25 | { 26 | } 27 | 28 | MimeInlineFile::~MimeInlineFile() 29 | {} 30 | 31 | /* [1] --- */ 32 | 33 | 34 | /* [2] Getters and Setters */ 35 | 36 | /* [2] --- */ 37 | 38 | 39 | /* [3] Protected methods */ 40 | 41 | void MimeInlineFile::prepare() 42 | { 43 | this->header += "Content-Disposition: inline\r\n"; 44 | 45 | /* !!! IMPORTANT !!! */ 46 | MimeFile::prepare(); 47 | } 48 | 49 | /* [3] --- */ 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimeinlinefile.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMEINLINEFILE_H 20 | #define MIMEINLINEFILE_H 21 | 22 | #include "mimefile.h" 23 | 24 | #include "publicdefine.h" 25 | 26 | class MimeInlineFile : public MimeFile 27 | { 28 | public: 29 | 30 | /* [1] Constructors and Destructors */ 31 | 32 | MimeInlineFile(QFile *f); 33 | ~MimeInlineFile(); 34 | 35 | /* [1] --- */ 36 | 37 | 38 | /* [2] Getters and Setters */ 39 | 40 | /* [2] --- */ 41 | 42 | protected: 43 | 44 | /* [3] Protected members */ 45 | 46 | /* [3] --- */ 47 | 48 | 49 | /* [4] Protected methods */ 50 | 51 | virtual void prepare(); 52 | 53 | /* [4] --- */ 54 | }; 55 | 56 | #endif // MIMEINLINEFILE_H 57 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimemessage.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * 文件名称: smtpclient.cpp 3 | * 简要描述: smtp客户端类,负责邮件信息初始化、连接、认证、发送等主要功能 4 | * 5 | * 创建日期: 2017年10月14日 6 | * 作者: lesliefish 7 | * 说明: 8 | ******************************************************************/ 9 | 10 | #ifndef MIMEMESSAGE_H 11 | #define MIMEMESSAGE_H 12 | 13 | #include "mimepart.h" 14 | #include "mimemultipart.h" 15 | #include "publicdefine.h" 16 | #include 17 | using namespace PublicDefine; 18 | 19 | class MimeMessage : public QObject 20 | { 21 | public: 22 | MimeMessage(bool createAutoMimeConent = true); 23 | ~MimeMessage(); 24 | 25 | typedef struct STRURECIPIENT 26 | { 27 | EmailAddress struRecipient; 28 | RecipientType enumType; 29 | }RecipientInfo; 30 | 31 | 32 | QList m_listRecipients; 33 | 34 | void setSender(EmailAddress& e); 35 | void addRecipient(EmailAddress& rcpt, RecipientType type = To); 36 | void setSubject(const QString & subject); 37 | void addPart(MimePart* part); 38 | 39 | void setInReplyTo(const QString& inReplyTo); 40 | 41 | void setHeaderEncoding(MimePart::Encoding); 42 | 43 | const EmailAddress & getSender() const; 44 | // const QList & getRecipients(RecipientType type = To) const; 45 | // const QString & getSubject() const; 46 | const QList & getParts() const; 47 | 48 | MimePart& getContent(); 49 | void setContent(MimePart *content); 50 | 51 | virtual QString toString(); 52 | 53 | public: 54 | QList m_listTos, m_listCcs, m_listBccs; 55 | EmailAddress m_struSender; 56 | RecipientInfo m_struRecipient; 57 | QString m_strSubject; 58 | QString mInReplyTo; 59 | MimePart *content; 60 | bool autoMimeContentCreated; 61 | 62 | MimePart::Encoding hEncoding; 63 | }; 64 | 65 | #endif // MIMEMESSAGE_H 66 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimetext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #include "mimetext.h" 20 | 21 | /* [1] Constructors and Destructors */ 22 | 23 | MimeText::MimeText(const QString &txt) 24 | { 25 | this->text = txt; 26 | this->cType = "text/plain"; 27 | this->cCharset = "utf-8"; 28 | this->cEncoding = _8Bit; 29 | } 30 | 31 | MimeText::~MimeText() { } 32 | 33 | /* [1] --- */ 34 | 35 | 36 | /* [2] Getters and Setters */ 37 | 38 | void MimeText::setText(const QString & text) 39 | { 40 | this->text = text; 41 | } 42 | 43 | const QString & MimeText::getText() const 44 | { 45 | return text; 46 | } 47 | 48 | /* [2] --- */ 49 | 50 | 51 | /* [3] Protected Methods */ 52 | 53 | void MimeText::prepare() 54 | { 55 | this->content.clear(); 56 | this->content.append(text); 57 | 58 | /* !!! IMPORTANT !!! */ 59 | MimePart::prepare(); 60 | } 61 | 62 | /* [3] --- */ 63 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/mimetext.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef MIMETEXT_H 20 | #define MIMETEXT_H 21 | 22 | #include "mimepart.h" 23 | 24 | #include "publicdefine.h" 25 | 26 | class MimeText : public MimePart 27 | { 28 | public: 29 | 30 | /* [1] Constructors and Destructors */ 31 | 32 | MimeText(const QString &text = ""); 33 | ~MimeText(); 34 | 35 | /* [1] --- */ 36 | 37 | 38 | /* [2] Getters and Setters*/ 39 | 40 | void setText(const QString & text); 41 | 42 | const QString & getText() const; 43 | 44 | /* [2] --- */ 45 | 46 | protected: 47 | 48 | /* [3] Protected members */ 49 | 50 | QString text; 51 | /* [3] --- */ 52 | 53 | 54 | /* [4] Protected methods */ 55 | 56 | void prepare(); 57 | 58 | /* [4] --- */ 59 | 60 | }; 61 | 62 | #endif // MIMETEXT_H 63 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/publicdefine.h: -------------------------------------------------------------------------------- 1 | #ifndef PUBLICDEFINE_H 2 | #define PUBLICDEFINE_H 3 | #include 4 | 5 | namespace PublicDefine 6 | { 7 | // 服务器认证类型 8 | enum AuthMethod 9 | { 10 | AuthPlain, 11 | AuthLogin 12 | }; 13 | 14 | //Smtp错误信息 15 | enum SmtpError 16 | { 17 | ConnectionTimeoutError, 18 | ResponseTimeoutError, 19 | SendDataTimeoutError, 20 | AuthenticationFailedError, 21 | ServerError, // 4xx 服务端错误 22 | ClientError // 5xx 客户端错误 23 | }; 24 | 25 | //服务器连接类型 26 | enum ConnectionType 27 | { 28 | TcpConnection, // 无加密 29 | SslConnection, // Ssl加密 30 | TlsConnection // STARTTLS加密 31 | }; 32 | 33 | //收件人类型 34 | enum RecipientType 35 | { 36 | To, // 普通收件人 37 | Cc, // 抄送 38 | Bcc // 密送 39 | }; 40 | 41 | //smtp 服务器配置数据结构体 42 | typedef struct SMTPPARAMS 43 | { 44 | QString strHost; 45 | int iPort; 46 | ConnectionType enumConnectionType; 47 | AuthMethod enumAuthMethod; 48 | QString strUserName; 49 | QString strPassword; 50 | int iConnectionTimeout; 51 | int iResponseTimeout; 52 | int iSendMessageTimeout; 53 | }SmtpParams; 54 | 55 | //邮箱地址,包括用户名和邮箱地址 56 | typedef struct EMAILADDRESS 57 | { 58 | QString strName; 59 | QString strAddr; 60 | }EmailAddress; 61 | 62 | 63 | } 64 | 65 | 66 | 67 | 68 | #endif // PUBLICDEFINE_H 69 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/quotedprintable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011-2012 - Tőkés Attila 3 | 4 | This file is part of SmtpClient for Qt. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | See the LICENSE file for more details. 17 | */ 18 | 19 | #ifndef QUOTEDPRINTABLE_H 20 | #define QUOTEDPRINTABLE_H 21 | 22 | #include 23 | #include 24 | 25 | #include "publicdefine.h" 26 | 27 | class QuotedPrintable : public QObject 28 | { 29 | Q_OBJECT 30 | public: 31 | 32 | static QString encode(const QByteArray &input); 33 | static QByteArray decode(const QString &input); 34 | 35 | private: 36 | QuotedPrintable(); 37 | }; 38 | 39 | #endif // QUOTEDPRINTABLE_H 40 | -------------------------------------------------------------------------------- /Tools/QtEmail/src/smtpclient.h: -------------------------------------------------------------------------------- 1 | #ifndef SMTPCLIENT_H 2 | #define SMTPCLIENT_H 3 | 4 | #include 5 | #include 6 | #include "mimemessage.h" 7 | #include "publicdefine.h" 8 | using namespace PublicDefine; 9 | 10 | class SmtpClient : public QObject 11 | { 12 | Q_OBJECT 13 | public: 14 | SmtpClient(const SmtpParams&); 15 | ~SmtpClient(); 16 | bool InitSocket(); 17 | const QString & GetResponseText() const; 18 | int GetResponseCode() const; 19 | bool ConnectToHost(); 20 | bool Login(); 21 | bool SendMail(MimeMessage& email); 22 | void Quit(); 23 | public: 24 | QTcpSocket *m_pSocket; 25 | QString name; 26 | SmtpParams m_struSmtpParams; 27 | QString m_strResponseText; 28 | int m_iResponseCode; 29 | class ResponseTimeoutException {}; 30 | class SendMessageTimeoutException {}; 31 | void WaitForResponse(); 32 | void SendMessage(const QString &text); 33 | 34 | private slots: 35 | void socketStateChanged(QAbstractSocket::SocketState state); 36 | void socketError(QAbstractSocket::SocketError error); 37 | void socketReadyRead(); 38 | 39 | signals: 40 | void smtpError(SmtpError e); 41 | }; 42 | 43 | #endif // SMTPCLIENT_H 44 | -------------------------------------------------------------------------------- /Tools/ReadMe: -------------------------------------------------------------------------------- 1 | 小工具目录 2 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/Main.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-10-19T18:28:06 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = Main 12 | TEMPLATE = app 13 | 14 | INCLUDEPATH += src/UI\ 15 | src/PublicGUI\ 16 | 17 | SOURCES += \ 18 | src/UI/MainWindow/mainwindow.cpp \ 19 | src/PublicGUI/FramelessWidget/framelesswidget.cpp \ 20 | src/UI/WarningDlg/warningdlg.cpp \ 21 | src/UI/About/aboutdlg.cpp \ 22 | src/main.cpp 23 | 24 | HEADERS += \ 25 | src/UI/MainWindow/mainwindow.h \ 26 | src/PublicGUI/FramelessWidget/framelesswidget.h \ 27 | src/UI/WarningDlg/warningdlg.h \ 28 | src/UI/About/aboutdlg.h 29 | 30 | FORMS += \ 31 | src/UI/MainWindow/mainwindow.ui \ 32 | src/PublicGUI/FramelessWidget/framelesswidget.ui \ 33 | src/UI/WarningDlg/warningdlg.ui \ 34 | src/UI/About/aboutdlg.ui 35 | 36 | DISTFILES += \ 37 | main.qss \ 38 | res/main.qss 39 | 40 | RESOURCES += \ 41 | res/main.qrc 42 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/README.md: -------------------------------------------------------------------------------- 1 | # ToosMainWindow 2 | 3 | 日常开发经常写一些小工具,界面来不及更改,现开发了一个通用的工具主界面,方便以后快速拿来就用 4 | 5 | 1、主窗口
6 |  ![image](https://github.com/lesliefish/Qt/blob/master/Tools/ToolsMainWindow/pic/main.png) 7 |  

8 | 2、退出
9 |  ![image](https://github.com/lesliefish/Qt/blob/master/Tools/ToolsMainWindow/pic/info.png) 10 |  

11 | 3、警告提示
12 |  ![image](https://github.com/lesliefish/Qt/blob/master/Tools/ToolsMainWindow/pic/warning.png) 13 |

14 | 4、关于
15 |  ![image](https://github.com/lesliefish/Qt/blob/master/Tools/ToolsMainWindow/pic/about.png) 16 |
17 | 18 | ##### 有空添加功能 19 | 20 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/pic/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/pic/about.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/pic/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/pic/info.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/pic/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/pic/main.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/pic/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/pic/warning.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/res/images/close.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/res/images/help.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/images/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/res/images/max.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/images/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/res/images/min.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/images/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/Tools/ToolsMainWindow/res/images/normal.png -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/res/main.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/max.png 4 | images/close.png 5 | images/min.png 6 | images/normal.png 7 | images/help.png 8 | 9 | 10 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/PublicGUI/FramelessWidget/framelesswidget.cpp: -------------------------------------------------------------------------------- 1 | #include "framelesswidget.h" 2 | #include "ui_framelesswidget.h" 3 | #include 4 | 5 | FramelessWidget::FramelessWidget(QWidget *parent) : 6 | QWidget(parent) 7 | , ui(new Ui::FramelessWidget) 8 | , m_bMouseIsPressed(false) 9 | { 10 | ui->setupUi(this); 11 | InitUI(); 12 | } 13 | 14 | FramelessWidget::~FramelessWidget() 15 | { 16 | delete ui; 17 | } 18 | 19 | void FramelessWidget::InitUI() 20 | { 21 | this->setWindowFlags(Qt::FramelessWindowHint); 22 | } 23 | 24 | 25 | //以下为无边框窗口可拖动功能 26 | void FramelessWidget::mousePressEvent(QMouseEvent *event) 27 | { 28 | if (event->button() == Qt::LeftButton) 29 | { 30 | this->setMouseTracking(true); 31 | m_bMouseIsPressed = true; 32 | m_pointMove = event->pos(); 33 | } 34 | } 35 | 36 | void FramelessWidget::mouseReleaseEvent(QMouseEvent *event) 37 | { 38 | m_bMouseIsPressed = false; 39 | } 40 | 41 | void FramelessWidget::mouseMoveEvent(QMouseEvent *event) 42 | { 43 | if (m_bMouseIsPressed) 44 | { 45 | QPoint pointPos = event->globalPos(); 46 | this->move(pointPos - m_pointMove); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/PublicGUI/FramelessWidget/framelesswidget.h: -------------------------------------------------------------------------------- 1 | #ifndef FRAMELESSWIDGET_H 2 | #define FRAMELESSWIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class FramelessWidget; 8 | } 9 | 10 | class FramelessWidget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit FramelessWidget(QWidget *parent = 0); 16 | ~FramelessWidget(); 17 | 18 | private: 19 | Ui::FramelessWidget *ui; 20 | 21 | void InitUI(); 22 | protected: 23 | QPoint m_pointMove; 24 | bool m_bMouseIsPressed; 25 | //实现鼠标对无边框窗口拖动 26 | void mousePressEvent(QMouseEvent *event); 27 | void mouseReleaseEvent(QMouseEvent *event); 28 | void mouseMoveEvent(QMouseEvent *event); 29 | }; 30 | 31 | #endif // FRAMELESSWIDGET_H 32 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/PublicGUI/FramelessWidget/framelesswidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FramelessWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 255 10 | 126 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | QWidget 18 | { 19 | background:white; 20 | border:1px solid rgb(128, 106, 255); 21 | border-radius: 1px; 22 | } 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/About/aboutdlg.cpp: -------------------------------------------------------------------------------- 1 | #include "aboutdlg.h" 2 | #include "ui_aboutdlg.h" 3 | #include 4 | #include 5 | 6 | AboutDlg::AboutDlg(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::AboutDlg) 9 | { 10 | ui->setupUi(this); 11 | this->setWindowFlags(Qt::FramelessWindowHint); 12 | this->setWindowTitle(ui->m_aboutTitleBtn->text()); 13 | connect(ui->m_aboutCloseBtn, &QPushButton::clicked, this, &AboutDlg::close); 14 | connect(ui->m_openBtn, &QPushButton::clicked, 15 | [=]() 16 | { 17 | QString filePath = QApplication::applicationDirPath(); 18 | QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); 19 | }); 20 | 21 | } 22 | 23 | AboutDlg::~AboutDlg() 24 | { 25 | delete ui; 26 | } 27 | 28 | void AboutDlg::mousePressEvent(QMouseEvent *e) 29 | { 30 | if (e->button() == Qt::LeftButton) 31 | { 32 | m_pointMove = e->globalPos() - pos(); 33 | e->accept(); 34 | } 35 | } 36 | 37 | void AboutDlg::mouseMoveEvent(QMouseEvent *e) 38 | { 39 | if (e->buttons() & Qt::LeftButton) 40 | { 41 | move(e->globalPos() - m_pointMove); 42 | e->accept(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/About/aboutdlg.h: -------------------------------------------------------------------------------- 1 | /** @file aboutdlg.h 2 | * @note 3 | * @brief 关于窗口 4 | * 5 | * @author lesliefish 6 | * @date 2017年10月21日 7 | * 8 | * @note detailed functional description of this document and comments 9 | * @note History 10 | * 11 | * @warning warning message related to this document 12 | */ 13 | 14 | #ifndef ABOUTDLG_H 15 | #define ABOUTDLG_H 16 | 17 | #include 18 | 19 | namespace Ui { 20 | class AboutDlg; 21 | } 22 | 23 | class AboutDlg : public QDialog 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit AboutDlg(QWidget *parent = 0); 29 | ~AboutDlg(); 30 | 31 | private: 32 | Ui::AboutDlg *ui; 33 | protected: 34 | //实现鼠标对无边框窗口拖动 35 | QPoint m_pointMove; 36 | void mousePressEvent(QMouseEvent *e); 37 | void mouseMoveEvent(QMouseEvent *e); 38 | }; 39 | 40 | #endif // ABOUTDLG_H 41 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/MainWindow/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mainwindow.h" 4 | #include "ui_mainwindow.h" 5 | 6 | 7 | MainWindow::MainWindow(QWidget *parent) : 8 | FramelessWidget(parent), 9 | ui(new Ui::MainWindow) 10 | { 11 | ui->setupUi(this); 12 | InitUI(); 13 | InitConnect(); 14 | } 15 | 16 | MainWindow::~MainWindow() 17 | { 18 | delete ui; 19 | } 20 | 21 | void MainWindow::InitUI() 22 | { 23 | this->setWindowFlags(Qt::FramelessWindowHint); 24 | this->setWindowTitle(ui->m_appNameBtn->text()); 25 | 26 | QString stylePath = QDir::currentPath() + "/res/main.qss"; 27 | QFile fileQss(stylePath); 28 | if(!fileQss.open(QFile::ReadOnly)) 29 | return; 30 | this->setStyleSheet(fileQss.readAll()); 31 | } 32 | 33 | void MainWindow::InitConnect() 34 | { 35 | connect(ui->m_helpBtn, &QPushButton::clicked, [=](){m_aboutDlg.exec();}); 36 | connect(ui->m_minBtn, &QPushButton::clicked, [=](){this->showMinimized();}); 37 | connect(ui->m_maxBtn, &QPushButton::clicked, [=](){this->isMaximized() ? this->showNormal() : this->showMaximized();}); 38 | connect(ui->m_closeBtn, &QPushButton::clicked,[=](){m_exitDlg.exec();}); 39 | connect(&m_exitDlg, &WarningDlg::SigExit, 40 | [=]() 41 | { 42 | if(!m_aboutDlg.isHidden()) 43 | m_aboutDlg.close(); 44 | this->close(); 45 | }); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/MainWindow/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "WarningDlg/warningdlg.h" 6 | #include "FramelessWidget/framelesswidget.h" 7 | #include "About/aboutdlg.h" 8 | 9 | namespace Ui { 10 | class MainWindow; 11 | } 12 | 13 | class MainWindow : public FramelessWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit MainWindow(QWidget *parent = 0); 19 | ~MainWindow(); 20 | 21 | private: 22 | Ui::MainWindow *ui; 23 | 24 | private: 25 | void InitUI(); 26 | void InitConnect(); 27 | WarningDlg m_exitDlg; 28 | AboutDlg m_aboutDlg; 29 | 30 | }; 31 | 32 | #endif // MAINWINDOW_H 33 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/WarningDlg/warningdlg.cpp: -------------------------------------------------------------------------------- 1 | #include "warningdlg.h" 2 | #include "ui_warningdlg.h" 3 | 4 | WarningDlg::WarningDlg(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::WarningDlg) 7 | { 8 | ui->setupUi(this); 9 | this->setWindowTitle(ui->m_titleTextBtn->text().trimmed()); 10 | this->setWindowFlags(Qt::FramelessWindowHint); 11 | connect(ui->m_closeBtn, &QPushButton::clicked,[=](){this->close();}); 12 | connect(ui->m_cancleBtn,&QPushButton::clicked,[=](){this->close();}); 13 | connect(ui->m_OKBtn, &QPushButton::clicked, this, &WarningDlg::Exit); 14 | } 15 | 16 | WarningDlg::~WarningDlg() 17 | { 18 | delete ui; 19 | } 20 | 21 | void WarningDlg::ShowWarning(const QString& title, const QString text) 22 | { 23 | WarningDlg* w = new WarningDlg(); 24 | w->ui->m_titleTextBtn->setText(title); 25 | w->ui->m_infoLabel->setText(text); 26 | w->ui->m_cancleBtn->setVisible(false); 27 | w->ui->m_OKBtn->setVisible(false); 28 | w->resize(210,180); 29 | w->exec(); 30 | } 31 | 32 | void WarningDlg::Exit() 33 | { 34 | this->close(); 35 | emit SigExit(); 36 | } 37 | void WarningDlg::mousePressEvent(QMouseEvent *e) 38 | { 39 | if (e->button() == Qt::LeftButton) 40 | { 41 | m_pointMove = e->globalPos() - pos(); 42 | e->accept(); 43 | } 44 | } 45 | 46 | void WarningDlg::mouseMoveEvent(QMouseEvent *e) 47 | { 48 | if (e->buttons() & Qt::LeftButton) 49 | { 50 | move(e->globalPos() - m_pointMove); 51 | e->accept(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/UI/WarningDlg/warningdlg.h: -------------------------------------------------------------------------------- 1 | /** @file aboutdlg.h 2 | * @note 3 | * @brief 退出提示窗口 4 | * 5 | * @author lesliefish 6 | * @date 2017年10月19日 7 | * 8 | * @note detailed functional description of this document and comments 9 | * @note History 10 | * 11 | * @warning warning message related to this document 12 | */ 13 | 14 | #ifndef WARNINGDLG_H 15 | #define WARNINGDLG_H 16 | 17 | #include 18 | #include 19 | 20 | namespace Ui { 21 | class WarningDlg; 22 | } 23 | 24 | class WarningDlg : public QDialog 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit WarningDlg(QWidget *parent = 0); 30 | 31 | static void ShowWarning(const QString& title, const QString text); 32 | ~WarningDlg(); 33 | 34 | private: 35 | Ui::WarningDlg *ui; 36 | void Exit(); 37 | protected: 38 | //实现鼠标对无边框窗口拖动 39 | QPoint m_pointMove; 40 | void mousePressEvent(QMouseEvent *e); 41 | void mouseMoveEvent(QMouseEvent *e); 42 | signals: 43 | void SigExit(); 44 | }; 45 | 46 | #endif // WARNINGDLG_H 47 | -------------------------------------------------------------------------------- /Tools/ToolsMainWindow/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow/mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | a.setApplicationName("未来之歌"); 8 | MainWindow w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /UI/ListView/src/DelegatePainter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/DelegatePainter.cpp -------------------------------------------------------------------------------- /UI/ListView/src/DelegatePainter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/DelegatePainter.h -------------------------------------------------------------------------------- /UI/ListView/src/ListView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/ListView.cpp -------------------------------------------------------------------------------- /UI/ListView/src/ListView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/ListView.h -------------------------------------------------------------------------------- /UI/ListView/src/StyledDelegate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/StyledDelegate.cpp -------------------------------------------------------------------------------- /UI/ListView/src/StyledDelegate.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/src/StyledDelegate.h -------------------------------------------------------------------------------- /UI/ListView/test/DataDefines.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/test/DataDefines.h -------------------------------------------------------------------------------- /UI/ListView/test/ItemDelegate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/test/ItemDelegate.cpp -------------------------------------------------------------------------------- /UI/ListView/test/ItemDelegate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "StyledDelegate.h" 4 | 5 | class ItemDelegate : public StyledDelegate 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | ItemDelegate(QObject *parent = Q_NULLPTR); 11 | ~ItemDelegate(); 12 | 13 | public: 14 | virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; 15 | 16 | protected: 17 | virtual int getMouseEventRole(const QPoint& pos, const QStyleOptionViewItem& option, const QModelIndex &index) const; 18 | 19 | }; 20 | -------------------------------------------------------------------------------- /UI/ListView/test/TestView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/ListView/test/TestView.cpp -------------------------------------------------------------------------------- /UI/ListView/test/TestView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ItemDelegate.h" 3 | #include "DataDefines.h" 4 | #include "ListView.h" 5 | 6 | class TestView : public ListView 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | TestView(QWidget *parent = Q_NULLPTR); 12 | ~TestView(); 13 | 14 | private: 15 | void initUi(); 16 | void addItem(const QList& infoList); 17 | 18 | private: 19 | ItemDelegate m_itemDelegate; 20 | QStandardItemModel m_model; 21 | }; 22 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/01/01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/01/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | QGraphicsScene* scene = new QGraphicsScene(); 11 | QGraphicsRectItem* rect = new QGraphicsRectItem(); 12 | rect->setRect(0, 0, 100, 100); 13 | 14 | scene->addItem(rect); 15 | QGraphicsView* view = new QGraphicsView(scene); 16 | 17 | view->show(); 18 | 19 | return a.exec(); 20 | } 21 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/02/02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/02/MyRect.cpp: -------------------------------------------------------------------------------- 1 | #include "MyRect.h" 2 | #include 3 | 4 | void MyRect::keyPressEvent(QKeyEvent *event) 5 | { 6 | if (event->key() == Qt::Key_Left) 7 | { 8 | setPos(x() - 10, y()); 9 | } 10 | else if (event->key() == Qt::Key_Right) 11 | { 12 | setPos(x() + 10, y()); 13 | } 14 | else if (event->key() == Qt::Key_Up) 15 | { 16 | setPos(x(), y() - 10); 17 | } 18 | else if (event->key() == Qt::Key_Down) 19 | { 20 | setPos(x(), y() + 10); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/02/MyRect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MyRect : public QObject, public QGraphicsRectItem 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | void keyPressEvent(QKeyEvent *event); 11 | 12 | }; 13 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/02/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MyRect.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | QGraphicsScene scene; 11 | MyRect* rect = new MyRect(); 12 | rect->setRect(0, 0, 100, 100); 13 | 14 | scene.addItem(rect); 15 | 16 | // make rect focusable 17 | rect->setFlag(QGraphicsItem::ItemIsFocusable); 18 | rect->setFocus(); 19 | 20 | QGraphicsView view; 21 | view.setScene(&scene); 22 | 23 | view.show(); 24 | 25 | return a.exec(); 26 | } 27 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/03.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | 4 | Bullet::Bullet() 5 | { 6 | setRect(0, 0, 10, 50); 7 | 8 | QTimer* timer = new QTimer(this); 9 | connect(timer, &QTimer::timeout, [&] {move(); }); 10 | 11 | timer->start(50); 12 | } 13 | 14 | Bullet::~Bullet() 15 | { 16 | } 17 | 18 | void Bullet::move() 19 | { 20 | setPos(x(), y() - 10); 21 | } 22 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Bullet : public QObject, public QGraphicsRectItem 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Bullet(); 12 | ~Bullet(); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/MyRect.cpp: -------------------------------------------------------------------------------- 1 | #include "MyRect.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | 6 | void MyRect::keyPressEvent(QKeyEvent *event) 7 | { 8 | if (event->key() == Qt::Key_Left) 9 | { 10 | setPos(x() - 10, y()); 11 | } 12 | else if (event->key() == Qt::Key_Right) 13 | { 14 | setPos(x() + 10, y()); 15 | } 16 | else if (event->key() == Qt::Key_Up) 17 | { 18 | setPos(x(), y() - 10); 19 | } 20 | else if (event->key() == Qt::Key_Down) 21 | { 22 | setPos(x(), y() + 10); 23 | } 24 | else if (event->key() == Qt::Key_Space) 25 | { 26 | // create a bullet 27 | Bullet * bullet = new Bullet(); 28 | bullet->setPos(x(), y()); 29 | scene()->addItem(bullet); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/MyRect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MyRect : public QObject, public QGraphicsRectItem 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | void keyPressEvent(QKeyEvent *event); 11 | 12 | }; 13 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/03/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MyRect.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | QGraphicsScene scene; 11 | MyRect* rect = new MyRect(); 12 | rect->setRect(0, 0, 100, 100); 13 | 14 | scene.addItem(rect); 15 | 16 | // make rect focusable 17 | rect->setFlag(QGraphicsItem::ItemIsFocusable); 18 | rect->setFocus(); 19 | 20 | QGraphicsView view; 21 | view.setScene(&scene); 22 | view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 23 | view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 24 | 25 | view.show(); 26 | 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/04.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | #include 4 | 5 | Bullet::Bullet() 6 | { 7 | setRect(0, 0, 10, 50); 8 | 9 | QTimer* timer = new QTimer(this); 10 | connect(timer, &QTimer::timeout, [&] {move(); }); 11 | 12 | timer->start(50); 13 | } 14 | 15 | Bullet::~Bullet() 16 | { 17 | } 18 | 19 | void Bullet::move() 20 | { 21 | setPos(x(), y() - 10); 22 | 23 | if (pos().y() + rect().height() < 0) 24 | { 25 | scene()->removeItem(this); 26 | delete this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Bullet : public QObject, public QGraphicsRectItem 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Bullet(); 12 | ~Bullet(); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/MyRect.cpp: -------------------------------------------------------------------------------- 1 | #include "MyRect.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | 6 | void MyRect::keyPressEvent(QKeyEvent *event) 7 | { 8 | if (event->key() == Qt::Key_Left) 9 | { 10 | setPos(x() - 10, y()); 11 | } 12 | else if (event->key() == Qt::Key_Right) 13 | { 14 | setPos(x() + 10, y()); 15 | } 16 | else if (event->key() == Qt::Key_Up) 17 | { 18 | setPos(x(), y() - 10); 19 | } 20 | else if (event->key() == Qt::Key_Down) 21 | { 22 | setPos(x(), y() + 10); 23 | } 24 | else if (event->key() == Qt::Key_Space) 25 | { 26 | // create a bullet 27 | Bullet * bullet = new Bullet(); 28 | bullet->setPos(x(), y()); 29 | scene()->addItem(bullet); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/MyRect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MyRect : public QObject, public QGraphicsRectItem 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | void keyPressEvent(QKeyEvent *event); 11 | 12 | }; 13 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/04/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MyRect.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | QGraphicsScene scene; 11 | MyRect* rect = new MyRect(); 12 | rect->setRect(0, 0, 100, 100); 13 | 14 | scene.addItem(rect); 15 | 16 | // make rect focusable 17 | rect->setFlag(QGraphicsItem::ItemIsFocusable); 18 | rect->setFocus(); 19 | 20 | QGraphicsView view; 21 | view.setScene(&scene); 22 | view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 23 | view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 24 | 25 | view.show(); 26 | view.setFixedSize(800, 600); 27 | scene.setSceneRect(0,0,800,600); 28 | 29 | return a.exec(); 30 | } 31 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/05.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/Bullet.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/05/Bullet.cpp -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Bullet : public QObject, public QGraphicsRectItem 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Bullet(); 12 | ~Bullet(); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.h" 2 | #include 3 | #include 4 | 5 | Enemy::Enemy() 6 | { 7 | int randomNumber = rand() % 700; 8 | setPos(randomNumber, 0); 9 | 10 | setRect(0, 0, 100, 100); 11 | 12 | QTimer* timer = new QTimer(this); 13 | 14 | connect(timer, &QTimer::timeout, [&] {move(); }); 15 | 16 | timer->start(50); 17 | } 18 | 19 | Enemy::~Enemy() 20 | { 21 | } 22 | 23 | void Enemy::move() 24 | { 25 | setPos(x(), y() + 5); 26 | if (pos().y() + rect().height() < 0) 27 | { 28 | scene()->removeItem(this); 29 | delete this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/Enemy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Enemy : public QObject, public QGraphicsRectItem 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Enemy(); 12 | ~Enemy(); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/MyRect.cpp: -------------------------------------------------------------------------------- 1 | #include "MyRect.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | #include "Enemy.h" 6 | 7 | void MyRect::keyPressEvent(QKeyEvent *event) 8 | { 9 | if (event->key() == Qt::Key_Left) 10 | { 11 | setPos(x() - 10, y()); 12 | } 13 | else if (event->key() == Qt::Key_Right) 14 | { 15 | setPos(x() + 10, y()); 16 | } 17 | else if (event->key() == Qt::Key_Up) 18 | { 19 | setPos(x(), y() - 10); 20 | } 21 | else if (event->key() == Qt::Key_Down) 22 | { 23 | setPos(x(), y() + 10); 24 | } 25 | else if (event->key() == Qt::Key_Space) 26 | { 27 | // create a bullet 28 | Bullet * bullet = new Bullet(); 29 | bullet->setPos(x(), y()); 30 | scene()->addItem(bullet); 31 | } 32 | } 33 | 34 | void MyRect::spawn() 35 | { 36 | Enemy * enemy = new Enemy(); 37 | scene()->addItem(enemy); 38 | } 39 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/MyRect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MyRect : public QObject, public QGraphicsRectItem 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | void keyPressEvent(QKeyEvent *event); 11 | 12 | public slots: 13 | void spawn(); 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/05/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/05/main.cpp -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/06.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | #include 4 | #include 5 | #include "Enemy.h" 6 | #include "Game.h" 7 | 8 | extern Game * gGame; // there is an external global object called game 9 | 10 | Bullet::Bullet(QGraphicsItem *parent /*= Q_NULLPTR*/) 11 | :QGraphicsRectItem(parent) 12 | { 13 | setRect(0, 0, 10, 50); 14 | 15 | QTimer * timer = new QTimer(this); 16 | connect(timer, &QTimer::timeout, [&] {move(); }); 17 | timer->start(50); 18 | } 19 | 20 | 21 | void Bullet::move() 22 | { 23 | auto items = collidingItems(); 24 | for (int i = 0; i < items.size(); ++i) 25 | { 26 | if (typeid(*items[i]) == typeid(Enemy)) 27 | { 28 | gGame->getScore().increase(); 29 | 30 | scene()->removeItem(items[i]); 31 | scene()->removeItem(this); 32 | 33 | delete items[i]; 34 | delete this; 35 | 36 | return; 37 | } 38 | } 39 | 40 | setPos(x(), y() - 10); 41 | 42 | if (pos().y() + rect().height() < 0) 43 | { 44 | scene()->removeItem(this); 45 | delete this; 46 | } 47 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Bullet : public QObject, public QGraphicsRectItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Bullet(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.h" 2 | #include 3 | #include 4 | #include "Game.h" 5 | 6 | extern Game * gGame; 7 | 8 | Enemy::Enemy(QGraphicsItem *parent /*= Q_NULLPTR*/) 9 | : QGraphicsRectItem(parent) 10 | { 11 | setPos(rand() % 700, 0); 12 | 13 | setRect(0, 0, 100, 100); 14 | 15 | QTimer* timer = new QTimer(this); 16 | 17 | connect(timer, &QTimer::timeout, [&] {move(); }); 18 | timer->start(50); 19 | } 20 | 21 | void Enemy::move() 22 | { 23 | setPos(x(), y() + 5); 24 | if (pos().y() > 600) 25 | { 26 | gGame->getHealth().decrease(); 27 | 28 | scene()->removeItem(this); 29 | delete this; 30 | } 31 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Enemy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Enemy : public QObject, public QGraphicsRectItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Enemy(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include 3 | 4 | Game::Game(QWidget *parent) 5 | : QGraphicsView(parent) 6 | { 7 | m_scene.setSceneRect(0, 0, 800, 600); 8 | 9 | setScene(&m_scene); 10 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 11 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 12 | 13 | setFixedSize(800, 600); 14 | 15 | m_player.setRect(0, 0, 100, 100); 16 | m_player.setPos(350, 500); 17 | 18 | m_player.setFlag(QGraphicsItem::ItemIsFocusable); 19 | m_player.setFocus(); 20 | m_scene.addItem(&m_player); 21 | 22 | m_scene.addItem(&m_score); 23 | 24 | m_health.setPos(m_health.x(), m_health.y() + 25); 25 | m_scene.addItem(&m_health); 26 | 27 | QTimer* timer = new QTimer(this); 28 | connect(timer, &QTimer::timeout, [&] { m_player.spawn(); }); 29 | timer->start(2000); 30 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Player.h" 7 | #include "Score.h" 8 | #include "Health.h" 9 | 10 | class Game : public QGraphicsView 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Game(QWidget *parent = Q_NULLPTR); 16 | 17 | public: 18 | Score& getScore() { return m_score; }; 19 | Player& getPlayer() { return m_player; }; 20 | Health& getHealth() { return m_health; }; 21 | 22 | private: 23 | QGraphicsScene m_scene; 24 | Player m_player; 25 | Score m_score; 26 | Health m_health; 27 | }; 28 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Health.cpp: -------------------------------------------------------------------------------- 1 | #include "Health.h" 2 | #include 3 | 4 | Health::Health(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_health = 3; 8 | 9 | setPlainText(tr("Health: ") + QString::number(m_health)); 10 | setDefaultTextColor(Qt::red); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Health::decrease() 15 | { 16 | m_health--; 17 | setPlainText(tr("Health: ") + QString::number(m_health)); 18 | } 19 | 20 | int Health::getHealth() 21 | { 22 | return m_health; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Health.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Health : public QGraphicsTextItem 8 | { 9 | 10 | public: 11 | Health(QGraphicsItem *parent = Q_NULLPTR); 12 | 13 | void decrease(); 14 | 15 | int getHealth(); 16 | 17 | private: 18 | int m_health; 19 | }; 20 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | #include "Enemy.h" 6 | 7 | Player::Player(QGraphicsItem *parent) 8 | : QGraphicsRectItem(parent) 9 | { 10 | } 11 | 12 | Player::~Player() 13 | { 14 | } 15 | 16 | void Player::keyPressEvent(QKeyEvent *event) 17 | { 18 | switch (event->key()) 19 | { 20 | case Qt::Key_Left: 21 | { 22 | if (pos().x() > 0) 23 | { 24 | setPos(x() - 10, y()); 25 | } 26 | } 27 | break; 28 | case Qt::Key_Right: 29 | { 30 | if (pos().x() + 100 < 800) 31 | { 32 | setPos(x() + 10, y()); 33 | } 34 | } 35 | break; 36 | case Qt::Key_Space: 37 | { 38 | Bullet* bullet = new Bullet; 39 | bullet->setPos(x(), y()); 40 | scene()->addItem(bullet); 41 | } 42 | default: 43 | break; 44 | } 45 | } 46 | 47 | void Player::spawn() 48 | { 49 | Enemy * enemy = new Enemy; 50 | scene()->addItem(enemy); 51 | } 52 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Player : public QObject, public QGraphicsRectItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Player(QGraphicsItem *parent = Q_NULLPTR); 13 | ~Player(); 14 | 15 | void keyPressEvent(QKeyEvent *event); 16 | 17 | public slots: 18 | void spawn(); 19 | }; 20 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Score.cpp: -------------------------------------------------------------------------------- 1 | #include "Score.h" 2 | #include 3 | 4 | Score::Score(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_score = 0; 8 | 9 | setPlainText(QString("Score: ") + QString::number(m_score)); 10 | setDefaultTextColor(Qt::blue); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Score::increase() 15 | { 16 | m_score++; 17 | setPlainText(QString("Score: ") + QString::number(m_score)); 18 | } 19 | 20 | int Score::getScore() 21 | { 22 | return m_score; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/Score.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Score : public QGraphicsTextItem 7 | { 8 | 9 | public: 10 | Score(QGraphicsItem *parent = Q_NULLPTR); 11 | 12 | void increase(); 13 | 14 | int getScore(); 15 | 16 | private: 17 | int m_score; 18 | }; 19 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/06/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Game.h" 3 | 4 | Game* gGame; 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | gGame = new Game; 11 | gGame->show(); 12 | 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/07.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | #include 4 | #include 5 | #include "Enemy.h" 6 | #include "Game.h" 7 | 8 | extern Game * gGame; // there is an external global object called game 9 | 10 | Bullet::Bullet(QGraphicsItem *parent /*= Q_NULLPTR*/) 11 | :QGraphicsRectItem(parent) 12 | { 13 | setRect(0, 0, 10, 50); 14 | 15 | QTimer * timer = new QTimer(this); 16 | connect(timer, &QTimer::timeout, [&] {move(); }); 17 | timer->start(50); 18 | } 19 | 20 | 21 | void Bullet::move() 22 | { 23 | auto items = collidingItems(); 24 | for (int i = 0; i < items.size(); ++i) 25 | { 26 | if (typeid(*items[i]) == typeid(Enemy)) 27 | { 28 | gGame->getScore().increase(); 29 | 30 | scene()->removeItem(items[i]); 31 | scene()->removeItem(this); 32 | 33 | delete items[i]; 34 | delete this; 35 | 36 | return; 37 | } 38 | } 39 | 40 | setPos(x(), y() - 10); 41 | 42 | if (pos().y() + rect().height() < 0) 43 | { 44 | scene()->removeItem(this); 45 | delete this; 46 | } 47 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Bullet : public QObject, public QGraphicsRectItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Bullet(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.h" 2 | #include 3 | #include 4 | #include "Game.h" 5 | 6 | extern Game * gGame; 7 | 8 | Enemy::Enemy(QGraphicsItem *parent /*= Q_NULLPTR*/) 9 | : QGraphicsRectItem(parent) 10 | { 11 | setPos(rand() % 700, 0); 12 | 13 | setRect(0, 0, 100, 100); 14 | 15 | QTimer* timer = new QTimer(this); 16 | 17 | connect(timer, &QTimer::timeout, [&] {move(); }); 18 | timer->start(50); 19 | } 20 | 21 | void Enemy::move() 22 | { 23 | setPos(x(), y() + 5); 24 | if (pos().y() > 600) 25 | { 26 | gGame->getHealth().decrease(); 27 | 28 | scene()->removeItem(this); 29 | delete this; 30 | } 31 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Enemy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Enemy : public QObject, public QGraphicsRectItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Enemy(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include 3 | #include 4 | 5 | Game::Game(QWidget *parent) 6 | : QGraphicsView(parent) 7 | { 8 | m_scene.setSceneRect(0, 0, 800, 600); 9 | 10 | setScene(&m_scene); 11 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 12 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 13 | 14 | setFixedSize(800, 600); 15 | 16 | m_player.setRect(0, 0, 100, 100); 17 | m_player.setPos(350, 500); 18 | 19 | m_player.setFlag(QGraphicsItem::ItemIsFocusable); 20 | m_player.setFocus(); 21 | m_scene.addItem(&m_player); 22 | 23 | m_scene.addItem(&m_score); 24 | 25 | m_health.setPos(m_health.x(), m_health.y() + 25); 26 | m_scene.addItem(&m_health); 27 | 28 | QTimer* timer = new QTimer(this); 29 | connect(timer, &QTimer::timeout, [&] { m_player.spawn(); }); 30 | timer->start(2000); 31 | 32 | QMediaPlayer * mediaPlayer = new QMediaPlayer; 33 | mediaPlayer->setMedia(QUrl("file:///C:\\Users\\Public\\Music\\Sample Music\\Sleep Away.mp3")); 34 | mediaPlayer->play(); 35 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Player.h" 7 | #include "Score.h" 8 | #include "Health.h" 9 | 10 | class Game : public QGraphicsView 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Game(QWidget *parent = Q_NULLPTR); 16 | 17 | public: 18 | Score& getScore() { return m_score; }; 19 | Player& getPlayer() { return m_player; }; 20 | Health& getHealth() { return m_health; }; 21 | 22 | private: 23 | QGraphicsScene m_scene; 24 | Player m_player; 25 | Score m_score; 26 | Health m_health; 27 | }; 28 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Health.cpp: -------------------------------------------------------------------------------- 1 | #include "Health.h" 2 | #include 3 | 4 | Health::Health(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_health = 3; 8 | 9 | setPlainText(tr("Health: ") + QString::number(m_health)); 10 | setDefaultTextColor(Qt::red); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Health::decrease() 15 | { 16 | m_health--; 17 | setPlainText(tr("Health: ") + QString::number(m_health)); 18 | } 19 | 20 | int Health::getHealth() 21 | { 22 | return m_health; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Health.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Health : public QGraphicsTextItem 8 | { 9 | 10 | public: 11 | Health(QGraphicsItem *parent = Q_NULLPTR); 12 | 13 | void decrease(); 14 | 15 | int getHealth(); 16 | 17 | private: 18 | int m_health; 19 | }; 20 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | #include "Enemy.h" 6 | 7 | Player::Player(QGraphicsItem *parent) 8 | : QGraphicsRectItem(parent) 9 | { 10 | m_player.setMedia(QUrl("file:///C:\\Users\\Public\\Music\\Sample Music\\Sleep Away.mp3")); 11 | } 12 | 13 | Player::~Player() 14 | { 15 | } 16 | 17 | void Player::keyPressEvent(QKeyEvent *event) 18 | { 19 | switch (event->key()) 20 | { 21 | case Qt::Key_Left: 22 | { 23 | if (pos().x() > 0) 24 | { 25 | setPos(x() - 10, y()); 26 | } 27 | } 28 | break; 29 | case Qt::Key_Right: 30 | { 31 | if (pos().x() + 100 < 800) 32 | { 33 | setPos(x() + 10, y()); 34 | } 35 | } 36 | break; 37 | case Qt::Key_Space: 38 | { 39 | Bullet* bullet = new Bullet; 40 | bullet->setPos(x(), y()); 41 | scene()->addItem(bullet); 42 | 43 | // play bulletsound 44 | if (m_player.state() == QMediaPlayer::PlayingState) 45 | { 46 | m_player.setPosition(0); 47 | } 48 | else if (m_player.state() == QMediaPlayer::StoppedState) 49 | { 50 | m_player.play(); 51 | } 52 | } 53 | default: 54 | break; 55 | } 56 | } 57 | 58 | void Player::spawn() 59 | { 60 | Enemy * enemy = new Enemy; 61 | scene()->addItem(enemy); 62 | } 63 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Player : public QObject, public QGraphicsRectItem 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | Player(QGraphicsItem *parent = Q_NULLPTR); 14 | ~Player(); 15 | 16 | void keyPressEvent(QKeyEvent *event); 17 | 18 | public slots: 19 | void spawn(); 20 | 21 | private: 22 | QMediaPlayer m_player; 23 | }; 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Score.cpp: -------------------------------------------------------------------------------- 1 | #include "Score.h" 2 | #include 3 | 4 | Score::Score(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_score = 0; 8 | 9 | setPlainText(QString("Score: ") + QString::number(m_score)); 10 | setDefaultTextColor(Qt::blue); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Score::increase() 15 | { 16 | m_score++; 17 | setPlainText(QString("Score: ") + QString::number(m_score)); 18 | } 19 | 20 | int Score::getScore() 21 | { 22 | return m_score; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/Score.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Score : public QGraphicsTextItem 7 | { 8 | 9 | public: 10 | Score(QGraphicsItem *parent = Q_NULLPTR); 11 | 12 | void increase(); 13 | 14 | int getScore(); 15 | 16 | private: 17 | int m_score; 18 | }; 19 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/07/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Game.h" 3 | 4 | Game* gGame; 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | gGame = new Game; 11 | gGame->show(); 12 | 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/08.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Resource Files 25 | 26 | 27 | 28 | 29 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 30 | qrc;* 31 | false 32 | 33 | 34 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | #include 4 | #include 5 | #include "Enemy.h" 6 | #include "Game.h" 7 | 8 | extern Game * gGame; // there is an external global object called game 9 | 10 | Bullet::Bullet(QGraphicsItem *parent /*= Q_NULLPTR*/) 11 | :QGraphicsPixmapItem(parent) 12 | { 13 | setPixmap(QPixmap(":/pic/bullet.png")); 14 | 15 | QTimer * timer = new QTimer(this); 16 | connect(timer, &QTimer::timeout, [&] {move(); }); 17 | timer->start(10); 18 | } 19 | 20 | 21 | void Bullet::move() 22 | { 23 | auto items = collidingItems(); 24 | for (int i = 0; i < items.size(); ++i) 25 | { 26 | if (typeid(*items[i]) == typeid(Enemy)) 27 | { 28 | gGame->getScore().increase(); 29 | 30 | scene()->removeItem(items[i]); 31 | scene()->removeItem(this); 32 | 33 | delete items[i]; 34 | delete this; 35 | 36 | return; 37 | } 38 | } 39 | 40 | setPos(x(), y() - 2); 41 | 42 | if (pos().y() < 0) 43 | { 44 | scene()->removeItem(this); 45 | delete this; 46 | } 47 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Bullet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Bullet : public QObject, public QGraphicsPixmapItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Bullet(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public slots: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.h" 2 | #include 3 | #include 4 | #include "Game.h" 5 | 6 | extern Game * gGame; 7 | 8 | Enemy::Enemy(QGraphicsItem *parent /*= Q_NULLPTR*/) 9 | : QGraphicsPixmapItem(parent) 10 | { 11 | setPos(rand() % 700, 0); 12 | 13 | setPixmap(QPixmap(":/pic/tiger.png")); 14 | 15 | QTimer* timer = new QTimer(this); 16 | 17 | connect(timer, &QTimer::timeout, [&] {move(); }); 18 | timer->start(10); 19 | } 20 | 21 | void Enemy::move() 22 | { 23 | setPos(x(), y() + 1); 24 | if (pos().y() > 600) 25 | { 26 | gGame->getHealth().decrease(); 27 | 28 | scene()->removeItem(this); 29 | delete this; 30 | } 31 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Enemy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Enemy : public QObject, public QGraphicsPixmapItem 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Enemy(QGraphicsItem *parent = Q_NULLPTR); 13 | 14 | public: 15 | void move(); 16 | }; 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include 3 | #include 4 | 5 | Game::Game(QWidget *parent) 6 | : QGraphicsView(parent) 7 | { 8 | m_scene.setSceneRect(0, 0, 800, 600); 9 | 10 | setScene(&m_scene); 11 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 12 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 13 | 14 | setFixedSize(800, 600); 15 | 16 | m_player.setPos(350, 500); 17 | 18 | m_player.setFlag(QGraphicsItem::ItemIsFocusable); 19 | m_player.setFocus(); 20 | m_scene.addItem(&m_player); 21 | 22 | m_scene.addItem(&m_score); 23 | 24 | m_health.setPos(m_health.x(), m_health.y() + 25); 25 | m_scene.addItem(&m_health); 26 | 27 | QTimer* timer = new QTimer(this); 28 | connect(timer, &QTimer::timeout, [&] { m_player.spawn(); }); 29 | timer->start(2000); 30 | 31 | QMediaPlayer * mediaPlayer = new QMediaPlayer; 32 | mediaPlayer->setMedia(QUrl("file:///C:\\Users\\Public\\Music\\Sample Music\\Sleep Away.mp3")); 33 | mediaPlayer->play(); 34 | } -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Player.h" 7 | #include "Score.h" 8 | #include "Health.h" 9 | 10 | class Game : public QGraphicsView 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Game(QWidget *parent = Q_NULLPTR); 16 | 17 | public: 18 | Score& getScore() { return m_score; }; 19 | Player& getPlayer() { return m_player; }; 20 | Health& getHealth() { return m_health; }; 21 | 22 | private: 23 | QGraphicsScene m_scene; 24 | Player m_player; 25 | Score m_score; 26 | Health m_health; 27 | }; 28 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Health.cpp: -------------------------------------------------------------------------------- 1 | #include "Health.h" 2 | #include 3 | 4 | Health::Health(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_health = 3; 8 | 9 | setPlainText(tr("Health: ") + QString::number(m_health)); 10 | setDefaultTextColor(Qt::red); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Health::decrease() 15 | { 16 | m_health--; 17 | setPlainText(tr("Health: ") + QString::number(m_health)); 18 | } 19 | 20 | int Health::getHealth() 21 | { 22 | return m_health; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Health.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class Health : public QGraphicsTextItem 8 | { 9 | 10 | public: 11 | Health(QGraphicsItem *parent = Q_NULLPTR); 12 | 13 | void decrease(); 14 | 15 | int getHealth(); 16 | 17 | private: 18 | int m_health; 19 | }; 20 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Player.cpp: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | #include 3 | #include 4 | #include "Bullet.h" 5 | #include "Enemy.h" 6 | 7 | Player::Player(QGraphicsItem *parent) 8 | : QGraphicsPixmapItem(parent) 9 | { 10 | m_player.setMedia(QUrl("file:///C:\\Users\\Public\\Music\\Sample Music\\Sleep Away.mp3")); 11 | setPixmap(QPixmap(":/pic/player.png")); 12 | } 13 | 14 | Player::~Player() 15 | { 16 | } 17 | 18 | void Player::keyPressEvent(QKeyEvent *event) 19 | { 20 | switch (event->key()) 21 | { 22 | case Qt::Key_Left: 23 | { 24 | if (pos().x() > 0) 25 | { 26 | setPos(x() - 10, y()); 27 | } 28 | } 29 | break; 30 | case Qt::Key_Right: 31 | { 32 | if (pos().x() + 100 < 800) 33 | { 34 | setPos(x() + 10, y()); 35 | } 36 | } 37 | break; 38 | case Qt::Key_Space: 39 | { 40 | Bullet* bullet = new Bullet; 41 | bullet->setPos(x(), y()); 42 | scene()->addItem(bullet); 43 | 44 | // play bulletsound 45 | if (m_player.state() == QMediaPlayer::PlayingState) 46 | { 47 | m_player.setPosition(0); 48 | } 49 | else if (m_player.state() == QMediaPlayer::StoppedState) 50 | { 51 | m_player.play(); 52 | } 53 | } 54 | default: 55 | break; 56 | } 57 | } 58 | 59 | void Player::spawn() 60 | { 61 | Enemy * enemy = new Enemy; 62 | scene()->addItem(enemy); 63 | } 64 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Player : public QObject, public QGraphicsPixmapItem 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | Player(QGraphicsItem *parent = Q_NULLPTR); 14 | ~Player(); 15 | 16 | void keyPressEvent(QKeyEvent *event); 17 | 18 | public slots: 19 | void spawn(); 20 | 21 | private: 22 | QMediaPlayer m_player; 23 | }; 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Score.cpp: -------------------------------------------------------------------------------- 1 | #include "Score.h" 2 | #include 3 | 4 | Score::Score(QGraphicsItem *parent /*= Q_NULLPTR*/) 5 | : QGraphicsTextItem(parent) 6 | { 7 | m_score = 0; 8 | 9 | setPlainText(QString("Score: ") + QString::number(m_score)); 10 | setDefaultTextColor(Qt::blue); 11 | setFont(QFont("times", 16)); 12 | } 13 | 14 | void Score::increase() 15 | { 16 | m_score++; 17 | setPlainText(QString("Score: ") + QString::number(m_score)); 18 | } 19 | 20 | int Score::getScore() 21 | { 22 | return m_score; 23 | } 24 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/Score.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Score : public QGraphicsTextItem 7 | { 8 | 9 | public: 10 | Score(QGraphicsItem *parent = Q_NULLPTR); 11 | 12 | void increase(); 13 | 14 | int getScore(); 15 | 16 | private: 17 | int m_score; 18 | }; 19 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/app.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | bullet.png 4 | tiger.png 5 | player.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/08/bullet.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Game.h" 3 | 4 | Game* gGame; 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | gGame = new Game; 11 | gGame->show(); 12 | 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/08/player.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/08/tiger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/08/tiger.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/09.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include "Tower.h" 3 | 4 | Game::Game(QWidget *parent) 5 | : QGraphicsView(parent) 6 | { 7 | m_scene = new QGraphicsScene(this); 8 | 9 | setScene(m_scene); 10 | 11 | Tower * tower = new Tower(); 12 | m_scene->addItem(tower); 13 | 14 | setFixedSize(800, 600); 15 | } 16 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/Game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Game : public QGraphicsView 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | Game(QWidget *parent = Q_NULLPTR); 11 | 12 | private: 13 | // member attributes 14 | QGraphicsScene * m_scene; 15 | }; 16 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/Tower.cpp: -------------------------------------------------------------------------------- 1 | #include "Tower.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | Tower::Tower(QGraphicsItem *parent) 8 | : QGraphicsPixmapItem(parent) 9 | { 10 | setPixmap(QPixmap(":/images/tower.png")); 11 | 12 | // create points vector 13 | QVector points; 14 | points << QPoint(1, 0) << QPoint(2, 0) << QPoint(3, 1) << QPoint(3, 2) << QPoint(2, 3) 15 | << QPoint(1, 3) << QPoint(0, 2) << QPoint(0, 1); 16 | 17 | // scale points 18 | int SCALE_FACTOR = 65; 19 | for (size_t i = 0, n = points.size(); i < n; i++) 20 | { 21 | points[i] *= SCALE_FACTOR; 22 | } 23 | 24 | m_attackArea = new QGraphicsPolygonItem(QPolygonF(points), this); 25 | 26 | 27 | // move the polygon 28 | QPointF poly_center(1.5, 1.5); 29 | poly_center *= SCALE_FACTOR; 30 | poly_center = mapToScene(poly_center);; 31 | QPointF tower_center(x() + 32, y() + 32); 32 | QLineF ln(poly_center, tower_center); 33 | m_attackArea->setPos(x() + ln.dx(), y() + ln.dy()); 34 | } 35 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/Tower.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Tower : public QObject, public QGraphicsPixmapItem 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | Tower(QGraphicsItem *parent = Q_NULLPTR); 14 | 15 | private: 16 | QGraphicsPolygonItem* m_attackArea{}; 17 | }; 18 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/app.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | tower.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Game.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | 8 | Game g; 9 | g.show(); 10 | 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/09/tower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/09/tower.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/10.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Bullet.cpp: -------------------------------------------------------------------------------- 1 | #include "Bullet.h" 2 | #include 3 | #include 4 | #include // qSin, qCos, qTan 5 | #include "Game.h" 6 | 7 | extern Game * game; 8 | 9 | Bullet::Bullet(QGraphicsItem *parent): QObject(),QGraphicsPixmapItem(parent){ 10 | // set graphics 11 | setPixmap(QPixmap(":/images/bullet.png")); 12 | 13 | 14 | // connect a timer to move() 15 | QTimer * move_timer = new QTimer(this); 16 | connect(move_timer,SIGNAL(timeout()),this,SLOT(move())); 17 | move_timer->start(50); 18 | } 19 | 20 | 21 | 22 | 23 | void Bullet::move(){ 24 | int STEP_SIZE = 30; 25 | double theta = rotation(); // degrees 26 | 27 | double dy = STEP_SIZE * qSin(qDegreesToRadians(theta)); 28 | double dx = STEP_SIZE * qCos(qDegreesToRadians(theta)); 29 | 30 | setPos(x()+dx, y()+dy); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Bullet.h: -------------------------------------------------------------------------------- 1 | #ifndef BULLET_H 2 | #define BULLET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Bullet: public QObject, public QGraphicsPixmapItem{ 9 | Q_OBJECT 10 | public: 11 | Bullet(QGraphicsItem * parent=0); 12 | public slots: 13 | void move(); 14 | }; 15 | 16 | #endif // BULLET_H 17 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Enemy.cpp: -------------------------------------------------------------------------------- 1 | #include "Enemy.h" 2 | #include 3 | #include 4 | #include 5 | 6 | Enemy::Enemy(QGraphicsItem *parent){ 7 | // set graphics 8 | setPixmap(QPixmap(":/images/enemy.png")); 9 | 10 | // set points 11 | points << QPointF(200,200) << QPointF(400,200); // move down-right then right 12 | point_index = 0; 13 | dest = points[0]; 14 | rotateToPoint(dest); 15 | 16 | // connect timer to move_forward 17 | QTimer * timer = new QTimer(this); 18 | connect(timer,SIGNAL(timeout()),this,SLOT(move_forward())); 19 | timer->start(150); 20 | } 21 | 22 | void Enemy::rotateToPoint(QPointF p){ 23 | QLineF ln(pos(),p); 24 | setRotation(-1 * ln.angle()); 25 | } 26 | 27 | void Enemy::move_forward(){ 28 | // if close to dest, rotate to next dest 29 | QLineF ln(pos(),dest); 30 | if (ln.length() < 5){ 31 | point_index++; 32 | if (point_index >= points.size()){ 33 | return; 34 | } 35 | dest = points[point_index]; 36 | rotateToPoint(dest); 37 | } 38 | 39 | // move enemy forward at current angle 40 | int STEP_SIZE = 5; 41 | double theta = rotation(); // degrees 42 | 43 | double dy = STEP_SIZE * qSin(qDegreesToRadians(theta)); 44 | double dx = STEP_SIZE * qCos(qDegreesToRadians(theta)); 45 | 46 | setPos(x()+dx, y()+dy); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Enemy.h: -------------------------------------------------------------------------------- 1 | #ifndef ENEMY_H 2 | #define ENEMY_H 3 | 4 | #include 5 | #include 6 | #include // list << element 7 | #include 8 | 9 | class Enemy: public QObject, public QGraphicsPixmapItem{ 10 | Q_OBJECT 11 | public: 12 | Enemy(QGraphicsItem * parent=0); 13 | void rotateToPoint(QPointF p); 14 | public slots: 15 | void move_forward(); 16 | private: 17 | QList points; 18 | QPointF dest; 19 | int point_index; 20 | }; 21 | 22 | #endif // ENEMY_H 23 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game.h" 2 | #include 3 | #include "Tower.h" 4 | #include "Bullet.h" 5 | #include "Enemy.h" 6 | 7 | Game::Game(): QGraphicsView(){ 8 | // create a scene 9 | scene = new QGraphicsScene(this); 10 | scene->setSceneRect(0,0,800,600); 11 | 12 | // set the scene 13 | setScene(scene); 14 | 15 | // create a tower 16 | Tower * t = new Tower(); 17 | t->setPos(250,250); 18 | 19 | // add the tower to scene 20 | scene->addItem(t); 21 | 22 | // alter window 23 | setFixedSize(800,600); 24 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 25 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 26 | 27 | // create enemy 28 | Enemy * enemy = new Enemy(); 29 | scene->addItem(enemy); 30 | } 31 | 32 | void Game::mousePressEvent(QMouseEvent *event){ 33 | //create a bullet 34 | Bullet * bullet = new Bullet(); 35 | bullet->setPos(event->pos()); 36 | bullet->setRotation(40); 37 | scene->addItem(bullet); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Game.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_H 2 | #define GAME_H 3 | 4 | #include 5 | #include 6 | 7 | class Game: public QGraphicsView{ 8 | public: 9 | // member functions 10 | Game(); 11 | void mousePressEvent(QMouseEvent *event); 12 | 13 | // member attributes 14 | QGraphicsScene * scene; 15 | }; 16 | 17 | #endif // GAME_H 18 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/Tower.h: -------------------------------------------------------------------------------- 1 | #ifndef TOWER_H 2 | #define TOWER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class Tower:public QObject, public QGraphicsPixmapItem{ 11 | Q_OBJECT 12 | public: 13 | Tower(QGraphicsItem * parent=0); 14 | double distanceTo(QGraphicsItem * item); 15 | void fire(); 16 | public slots: 17 | void aquire_target(); 18 | private: 19 | QGraphicsPolygonItem * attack_area; 20 | QPointF attack_dest; 21 | bool has_target; 22 | }; 23 | 24 | #endif // TOWER_H 25 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/app.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | tower.png 4 | bullet.png 5 | enemy.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/10/bullet.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/10/enemy.png -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Game.h" 3 | 4 | /* 5 | Tutorial topics: 6 | QGraphicsItem::collidingItems() 7 | dynamic_cast<>() 8 | */ 9 | 10 | Game * game; 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | QApplication a(argc, argv); 15 | 16 | game = new Game(); 17 | game->show(); 18 | 19 | return a.exec(); 20 | } 21 | -------------------------------------------------------------------------------- /UI/QGraphicsView/QGraphicsViewFramework/10/tower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QGraphicsView/QGraphicsViewFramework/10/tower.png -------------------------------------------------------------------------------- /UI/QGraphicsView/readme.txt: -------------------------------------------------------------------------------- 1 | QGraphicsView -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QQFriendList", "QQFriendList\QQFriendList.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/FriendTree/FriendTree.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/FriendTree/FriendTree.cpp -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/FriendTree/FriendTree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/FriendTree/FriendTree.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/FriendTree/ItemDelegate.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/FriendTree/ItemDelegate.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/GlobalDefines.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/GlobalDefines.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/DelegatePainter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/DelegatePainter.cpp -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/DelegatePainter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/DelegatePainter.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/StyledDelegate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/StyledDelegate.cpp -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/StyledDelegate.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/StyledDelegate.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/TreeView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/TreeView.cpp -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/PublicGui/TreeView/TreeView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/PublicGui/TreeView/TreeView.h -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/QQFriendList.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resources/images/expand_down.svg 4 | Resources/images/expand_right.svg 5 | Resources/images/portrait_boy.svg 6 | Resources/images/portrait_girl.svg 7 | Resources/images/busy-im.svg 8 | Resources/images/leave-im.svg 9 | Resources/images/online-im.svg 10 | Resources/images/video.svg 11 | Resources/images/video_hover.svg 12 | 13 | 14 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/busy-im.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/expand_down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/expand_right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/leave-im.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/online-im.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/video.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/Resources/images/video_hover.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /UI/QQFriendList/QQFriendList/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/QQFriendList/QQFriendList/main.cpp -------------------------------------------------------------------------------- /UI/QTableView/QTableView/QTableView.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-11-07T20:47:43 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QTableView 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += \ 27 | main.cpp \ 28 | widget.cpp \ 29 | headerview.cpp 30 | 31 | HEADERS += \ 32 | widget.h \ 33 | headerview.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | -------------------------------------------------------------------------------- /UI/QTableView/QTableView/headerview.cpp: -------------------------------------------------------------------------------- 1 | #include "headerview.h" 2 | 3 | HeaderView::HeaderView(Qt::Orientation orientation, QWidget* parent) 4 | : QHeaderView(orientation, parent) 5 | { 6 | 7 | } 8 | 9 | void HeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const 10 | { 11 | painter->save(); 12 | QHeaderView::paintSection(painter, rect, logicalIndex); 13 | painter->restore(); 14 | 15 | if(logicalIndex == 0) 16 | { 17 | QStyleOptionButton option; 18 | option.iconSize = QSize(10,10); 19 | option.rect = rect; 20 | 21 | if(isOn) 22 | option.state = QStyle::State_On; 23 | else 24 | option.state = QStyle::State_Off; 25 | this->style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &option, painter); 26 | } 27 | } 28 | 29 | 30 | void HeaderView::mousePressEvent(QMouseEvent *event) 31 | { 32 | if (isOn) 33 | isOn = false; 34 | else 35 | isOn = true; 36 | this->update(); 37 | QHeaderView::mousePressEvent(event); 38 | } 39 | -------------------------------------------------------------------------------- /UI/QTableView/QTableView/headerview.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADERVIEW_H 2 | #define HEADERVIEW_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HeaderView : public QHeaderView 9 | { 10 | public: 11 | HeaderView(Qt::Orientation orientation, QWidget* parent = 0); 12 | 13 | protected: 14 | void paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const; 15 | 16 | void mousePressEvent(QMouseEvent* event); 17 | 18 | private: 19 | bool isOn; 20 | }; 21 | 22 | #endif // HEADERVIEW_H 23 | -------------------------------------------------------------------------------- /UI/QTableView/QTableView/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /UI/QTableView/QTableView/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | Widget::Widget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::Widget) 7 | { 8 | ui->setupUi(this); 9 | 10 | //初始化 11 | Init(); 12 | } 13 | 14 | Widget::~Widget() 15 | { 16 | delete ui; 17 | } 18 | 19 | void Widget::Init() 20 | { 21 | QStringList strHeader; 22 | strHeader << " " 23 | << "name" 24 | << "age" 25 | << "sex"; 26 | 27 | if(NULL == m_model) 28 | { 29 | m_model = new QStandardItemModel(); 30 | } 31 | 32 | ui->filterEdit->setVisible(false); 33 | ui->filterLabel->setVisible(false); 34 | 35 | //表头增加复选框方法 36 | HeaderView *header = new HeaderView(Qt::Horizontal, ui->tableView); 37 | ui->tableView->setHorizontalHeader(header); 38 | 39 | 40 | //添加表头数据 41 | //m_model->setHorizontalHeaderLabels(strHeader); 42 | //设置列数 43 | m_model->setColumnCount(strHeader.size()); 44 | //设置行数 45 | m_model->setRowCount(2); 46 | //隐藏列表头 47 | ui->tableView->verticalHeader()->hide(); 48 | 49 | //setModel 50 | ui->tableView->setModel(m_model); 51 | 52 | //表头qss设置 53 | QString strHeaderQss; 54 | strHeaderQss = "QHeaderView::section { background:green; color:white;min-height:3em;}"; 55 | ui->tableView->setStyleSheet(strHeaderQss); 56 | 57 | //表头设置最后一列数据填充整个控件 58 | ui->tableView->horizontalHeader()->setStretchLastSection(true); 59 | 60 | //表头内容均分填充整个控件 61 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 62 | } 63 | -------------------------------------------------------------------------------- /UI/QTableView/QTableView/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "headerview.h" 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Widget(QWidget *parent = 0); 18 | ~Widget(); 19 | 20 | private: 21 | Ui::Widget *ui; 22 | 23 | private: 24 | QStandardItemModel* m_model; 25 | 26 | private: 27 | void Init(); 28 | 29 | }; 30 | 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /UI/QTableWidget/QTableWidget.cc: -------------------------------------------------------------------------------- 1 | 2 | ui->deviceTable->verticalHeader()->setFixedWidth(25); // 设置列表头宽度 3 | ui->deviceTable->horizontalHeader()->setFixedHeight(33);//设置行表头高度 4 | ui->deviceTable->verticalHeader()->setHidden(true); //隐藏列表头 5 | ui->deviceTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); //表格内容自适应文本内容 6 | ui->deviceTable->setAlternatingRowColors(true);//表格文本隔行换色 -------------------------------------------------------------------------------- /UI/Qt控件提升/MyselfWidget.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-11-05T18:18:19 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = MyselfWidget 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += \ 27 | main.cpp \ 28 | widget.cpp \ 29 | passwordlineedit.cpp 30 | 31 | HEADERS += \ 32 | widget.h \ 33 | passwordlineedit.h 34 | 35 | FORMS += \ 36 | widget.ui 37 | -------------------------------------------------------------------------------- /UI/Qt控件提升/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /UI/Qt控件提升/passwordlineedit.cpp: -------------------------------------------------------------------------------- 1 | #include "passwordlineedit.h" 2 | 3 | PasswordLineEdit::PasswordLineEdit(QWidget* parent): 4 | QLineEdit(parent) 5 | { 6 | this->setMaxLength(8); 7 | this->setEchoMode(QLineEdit::Password);//设置为密码类型 8 | } 9 | -------------------------------------------------------------------------------- /UI/Qt控件提升/passwordlineedit.h: -------------------------------------------------------------------------------- 1 | #ifndef PASSWORDLINEEDIT_H 2 | #define PASSWORDLINEEDIT_H 3 | #include 4 | 5 | class PasswordLineEdit : public QLineEdit 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | PasswordLineEdit(QWidget* parent = 0); 11 | }; 12 | 13 | #endif // PASSWORDLINEEDIT_H 14 | -------------------------------------------------------------------------------- /UI/Qt控件提升/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | Widget::Widget(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::Widget) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | Widget::~Widget() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /UI/Qt控件提升/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Widget; 8 | } 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Widget(QWidget *parent = 0); 16 | ~Widget(); 17 | 18 | private: 19 | Ui::Widget *ui; 20 | }; 21 | 22 | #endif // WIDGET_H 23 | -------------------------------------------------------------------------------- /UI/Qt控件提升/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 311 10 | 190 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 90 20 | 80 21 | 141 22 | 31 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | PasswordLineEdit 31 | QLineEdit 32 |
passwordlineedit.h
33 |
34 |
35 | 36 | 37 |
38 | -------------------------------------------------------------------------------- /UI/Toast/Toast.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Toast", "Toast\Toast.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /UI/Toast/Toast/Toast.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/Toast/Toast/Toast.cpp -------------------------------------------------------------------------------- /UI/Toast/Toast/Toast.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/Toast/Toast/Toast.h -------------------------------------------------------------------------------- /UI/Toast/Toast/Toast.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /UI/Toast/Toast/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/Toast/Toast/main.cpp -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisplayChangedEventDemo", "DisplayChangedEventDemo\DisplayChangedEventDemo.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.cpp -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lesliefish/Qt/5dc7ef1008f8f83b5381e37db5d22f2b8225369e/UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.h -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo/DisplayChangedEventDemo.ui: -------------------------------------------------------------------------------- 1 | 2 | DisplayChangedEventDemoClass 3 | 4 | 5 | DisplayChangedEventDemoClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | DisplayChangedEventDemo 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /UI/分辨率修改事件/DisplayChangedEventDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "DisplayChangedEventDemo.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | DisplayChangedEventDemo w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | --------------------------------------------------------------------------------