├── .gitignore ├── ConcurrentExamples ├── ConcurrentExamples.assets │ ├── UseQThread1-tuya.gif │ ├── UseQThread2-tuya.gif │ ├── image-20230218120351892.png │ ├── image-20230218120716966.png │ ├── image-20230224151913976.png │ ├── image-20230226215928039.png │ ├── image-20230309210116047.png │ ├── image-20230312113522409.png │ └── ioThread-tuya.gif ├── ConcurrentExamples.md ├── ConcurrentExamples.pro ├── IOThread │ ├── IOThread.pro │ ├── iothread.cpp │ ├── iothread.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── UseConcurrent │ ├── Map │ │ ├── Map.pro │ │ ├── main.cpp │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ ├── Mapped │ │ ├── Mapped.pro │ │ ├── main.cpp │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ ├── MappedReduced │ │ ├── MappedReduced.pro │ │ └── main.cpp │ ├── RunFunction │ │ ├── RunFunction.pro │ │ ├── main.cpp │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ └── UseConcurrent.pro ├── UseQThread1 │ ├── UseQThread1.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ ├── widget.ui │ ├── work1.cpp │ ├── work1.h │ ├── work2.cpp │ └── work2.h ├── UseQThread2 │ ├── UseQThread2.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ ├── widget.ui │ ├── workthread.cpp │ └── workthread.h └── UseQThreadPool │ ├── UseQThreadPool.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── Experience ├── Experience.assets │ └── image-20230107153044329.png ├── Experience.md ├── Experience.pro └── UsePath │ ├── UsePath.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── FFmpegDemo ├── AVIOReading │ ├── AVIOReading.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── DecodeAudio │ ├── DecodeAudio.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── FFmpegDemo.assets │ ├── AVIOReading-tuya.gif │ ├── DecodeAudio.gif │ ├── VideoCamera1.gif │ ├── VideoCamera2-tuya.gif │ ├── VideoPlay-tuya.gif │ ├── VideoPlayHW-tuya.png │ ├── image-20221015204308041.png │ ├── image-20221017232820037.png │ ├── image-20221020192642223.png │ ├── image-20221024094954935.png │ ├── image-20221027235118681.png │ ├── image-20230101133211140.png │ ├── image-20230104155424623.png │ └── image-20240415223552799.png ├── FFmpegDemo.md ├── FFmpegDemo.pro ├── Screencap │ ├── Screencap.pro │ ├── Screencap │ │ ├── Screencap.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videocodec.cpp │ │ ├── videocodec.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoCamera1 │ ├── VideoCamera1.pro │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoCamera2 │ ├── VideoCamera2.pro │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ ├── videodecode.h │ │ ├── videosave.cpp │ │ └── videosave.h │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoCamera3 │ ├── VideoCamera3.pro │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoPlay │ ├── VideoPlay.pro │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoPlayGL1 │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── VideoPlayGL1.pro │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoPlayGL2 │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── VideoPlayGL2.pro │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoPlayHW │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── VideoPlayHW.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── VideoPlayHWGL │ ├── VideoPlay │ │ ├── VideoPlay.pri │ │ ├── readthread.cpp │ │ ├── readthread.h │ │ ├── videodecode.cpp │ │ └── videodecode.h │ ├── VideoPlayHWGL.pro │ ├── fragment.fsh │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── vertex.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui └── VideoPlaySave │ ├── VideoPlay │ ├── VideoPlay.pri │ ├── readthread.cpp │ ├── readthread.h │ ├── videodecode.cpp │ └── videodecode.h │ ├── VideoPlaySave.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── FunctionalModule ├── DeviceManagement │ ├── DeviceManagement.pro │ ├── comchange.cpp │ ├── comchange.h │ ├── head.h │ ├── main.cpp │ ├── mousekeytest.cpp │ ├── mousekeytest.h │ ├── mousekeytest.ui │ ├── porttest.cpp │ ├── porttest.h │ ├── porttest.ui │ ├── serialportstatus.cpp │ ├── serialportstatus.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── FunctionalModule.assets │ ├── Dump.gif │ ├── MouseKeyEvent.gif │ ├── NtpClient.gif │ ├── QLog.gif │ ├── QMPlayer.gif │ ├── QMWidget.gif │ ├── image-20220408223533219.png │ ├── image-20221121125725058.png │ ├── image-20240502211734717.png │ ├── log.PNG │ ├── mouseEvent-tuya.gif │ ├── windowRect1-tuya.gif │ ├── windowRect2-tuya.gif │ ├── 串口状态检测.gif │ └── 鼠标键盘热插拔监测.gif ├── FunctionalModule.md ├── FunctionalModule.pro ├── MouseKeyEvent │ ├── GlobalMouseKey │ │ ├── GlobalMouseKey.pri │ │ ├── globalkeyevent.h │ │ ├── globalkeyevent_win.cpp │ │ ├── globalkeyevent_x11.cpp │ │ ├── globalmouseevent.h │ │ ├── globalmouseevent_win.cpp │ │ └── globalmouseevent_x11.cpp │ ├── MouseKeyEvent.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── NtpClient │ ├── NtpClient.pro │ ├── main.cpp │ ├── ntpclient.cpp │ ├── ntpclient.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QLog │ ├── QLog.pro │ ├── QLog │ │ ├── QLog.pri │ │ ├── head.h │ │ ├── logconfig.cpp │ │ ├── logconfig.h │ │ ├── loginput.cpp │ │ ├── loginput.h │ │ ├── logsavebase.cpp │ │ ├── logsavebase.h │ │ ├── logsavetxt.cpp │ │ ├── logsavetxt.h │ │ ├── logwidgetbase.cpp │ │ ├── logwidgetbase.h │ │ ├── logwidgettext.cpp │ │ ├── logwidgettext.h │ │ └── logwidgettext.ui │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QMPlayer │ ├── Module │ │ ├── Module.pri │ │ ├── controlbar.cpp │ │ ├── controlbar.h │ │ ├── controlbar.ui │ │ ├── sidebar.cpp │ │ ├── sidebar.h │ │ ├── sidebar.ui │ │ ├── slidervideo.cpp │ │ ├── slidervideo.h │ │ ├── titlebar.cpp │ │ ├── titlebar.h │ │ └── titlebar.ui │ ├── QMPlayer.pro │ ├── Style │ │ ├── image │ │ │ ├── Closevolume.png │ │ │ ├── close.png │ │ │ ├── max.png │ │ │ ├── min.png │ │ │ ├── next.png │ │ │ ├── next_hover.png │ │ │ ├── play.png │ │ │ ├── play_hover.png │ │ │ ├── previous.png │ │ │ ├── previous_hover.png │ │ │ ├── restore.png │ │ │ ├── setup.png │ │ │ ├── stop.png │ │ │ ├── stop_hover.png │ │ │ └── volume.png │ │ └── main.css │ ├── WidgetBase │ │ ├── WidgetBase.pri │ │ ├── mwidgetbase.cpp │ │ └── mwidgetbase.h │ ├── main.cpp │ ├── res.qrc │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QMWidget │ ├── Module │ │ ├── Module.pri │ │ ├── controlbar.cpp │ │ ├── controlbar.h │ │ ├── controlbar.ui │ │ ├── titlebar.cpp │ │ ├── titlebar.h │ │ └── titlebar.ui │ ├── QMWidget.pro │ ├── Style │ │ ├── image │ │ │ ├── close.png │ │ │ ├── max.png │ │ │ ├── min.png │ │ │ └── restore.png │ │ └── main.css │ ├── WidgetBase │ │ ├── WidgetBase.pri │ │ ├── head.h │ │ ├── mwidgetbase.cpp │ │ └── mwidgetbase.h │ ├── main.cpp │ ├── res.qrc │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QrCodeDemo │ ├── QRCode │ │ ├── QRCode.pri │ │ ├── lib.pri │ │ ├── qrcodeview.cpp │ │ ├── qrcodeview.h │ │ ├── qrencode │ │ │ ├── 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 │ │ │ ├── rsecc.c │ │ │ ├── rsecc.h │ │ │ ├── split.c │ │ │ └── split.h │ │ ├── qrencodeLib │ │ │ ├── include │ │ │ │ └── qrencode.h │ │ │ ├── lib │ │ │ │ ├── pkgconfig │ │ │ │ │ └── libqrencode.pc │ │ │ │ ├── qrencode.lib │ │ │ │ └── qrencoded.lib │ │ │ ├── share │ │ │ │ └── man │ │ │ │ │ └── man1 │ │ │ │ │ └── qrencode.1 │ │ │ └── 编译说明.md │ │ └── src.pri │ ├── QrCodeDemo.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── ScanFile │ ├── ScanFile.pro │ ├── ScanFileLib │ │ ├── CMakeLists.txt │ │ ├── ScanFIle.cpp │ │ ├── ScanFile.h │ │ ├── SpinLock.h │ │ ├── ThreadPool.h │ │ └── ThreadSafeQueue.h │ ├── ThreadPool.h │ ├── include │ │ ├── ScanFile.h │ │ ├── SpinLock.h │ │ └── ThreadSafeQueue.h │ ├── lib │ │ ├── ScanFile.dll │ │ ├── ScanFile.lib │ │ ├── ScanFiled.dll │ │ └── ScanFiled.lib │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── SnippingTool │ ├── SnippingTool.pro │ ├── icon.ico │ ├── img │ │ ├── cancel.ico │ │ ├── clipping.ico │ │ ├── precinct.ico │ │ └── save.ico │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── playimage.cpp │ ├── playimage.h │ ├── rc.qrc │ ├── screenrect.cpp │ ├── screenrect.h │ ├── windowrect.cpp │ └── windowrect.h ├── TestCrashHandler │ ├── CrashHandler │ │ ├── CrashHandler.pri │ │ ├── crashhandler.cpp │ │ └── crashhandler.h │ ├── TestCrashHandler.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui └── WindowRect │ ├── WindowRect.pro │ ├── main.cpp │ ├── widget.cpp │ └── widget.h ├── GraphicsviewDemo ├── GraphicsItem │ ├── 1.png │ ├── GraphicsItem.pro │ ├── GraphicsItem_resource.rc │ ├── image.qrc │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── qgraphicspointsitem.cpp │ └── qgraphicspointsitem.h ├── GraphicsviewDemo.assets │ └── GraphicsItem-tuya.gif ├── GraphicsviewDemo.md └── GraphicsviewDemo.pro ├── LICENSE ├── MapExamples ├── MapDownload │ ├── MapDownload.pro │ ├── bingformula.cpp │ ├── bingformula.h │ ├── downloadthread.cpp │ ├── downloadthread.h │ ├── downloadthreads.cpp │ ├── downloadthreads.h │ ├── formula.cpp │ ├── formula.h │ ├── main.cpp │ ├── mapStruct.h │ ├── mapinput.cpp │ ├── mapinput.h │ ├── mapinput.ui │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── MapExamples.assets │ ├── image-20240510221601118.png │ ├── image-20240510221755393.png │ ├── image-20240510222139643.png │ └── image-20240602194658596.png ├── MapExamples.md ├── MapExamples.pro ├── MapView │ ├── MapView.pro │ ├── MapView │ │ ├── MapView.pri │ │ ├── mapgraphicsview.cpp │ │ └── mapgraphicsview.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── MapView2 │ ├── MapView │ │ ├── MapView.pri │ │ ├── bingformula.cpp │ │ ├── bingformula.h │ │ ├── mapStruct.h │ │ ├── mapgraphicsview.cpp │ │ └── mapgraphicsview.h │ ├── MapView2.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui └── MapView3 │ ├── MapView │ ├── MapView.pri │ ├── bingformula.cpp │ ├── bingformula.h │ ├── geturl.cpp │ ├── geturl.h │ ├── graphicsitemgroup.cpp │ ├── graphicsitemgroup.h │ ├── mapStruct.h │ ├── mapgraphicsview.cpp │ └── mapgraphicsview.h │ ├── MapView3.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── OpenCVDemo ├── OpenCVDemo.assets │ └── VideoPlay1-tuya.gif ├── OpenCVDemo.md ├── OpenCVDemo.pro └── VideoPlay │ ├── VideoPlay.pro │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── videodisplay.cpp │ ├── videodisplay.h │ ├── videodisplay.ui │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── OpenGLDemo ├── OpenGLDemo.assets │ ├── TestOpenGLWindow1-tuya.gif │ └── TestOpenGLWindow2-tuya.gif ├── OpenGLDemo.md ├── OpenGLDemo.pro └── TestOpenGLWindow │ ├── Shader.qrc │ ├── TestOpenGLWindow.pro │ ├── fragmentShader.fsh │ ├── main.cpp │ ├── openglwidget.cpp │ ├── openglwidget.h │ ├── openglwindow.cpp │ ├── openglwindow.h │ ├── vertexShader.vsh │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PaintingDemo ├── Concentriccircles │ ├── Concentriccircles.pro │ ├── circlewidget.cpp │ ├── circlewidget.h │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── Imagecomposition │ ├── Image.qrc │ ├── Imagecomposition.pro │ ├── images │ │ ├── butterfly.png │ │ └── checker.png │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PainterPaths │ ├── PainterPaths.pro │ ├── main.cpp │ ├── renderarea.cpp │ ├── renderarea.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PaintingDemo.assets │ ├── Concentriccircles-tuya.gif │ ├── TransformDemo-tuya.gif │ ├── Transformations.gif │ ├── basicdrawing.gif │ ├── image-20220801122927716.png │ └── playImage.gif ├── PaintingDemo.md ├── PaintingDemo.pro ├── PlayImage │ ├── 0.jpg │ ├── 1.jpg │ ├── 2.jpg │ ├── PlayImage.pro │ ├── image.qrc │ ├── main.cpp │ ├── playimage.cpp │ ├── playimage.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── TransformDemo │ ├── TransformDemo.pro │ ├── main.cpp │ ├── renderarea.cpp │ ├── renderarea.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── Transformations │ ├── Transformations.pro │ ├── main.cpp │ ├── renderarea.cpp │ ├── renderarea.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui └── basicdrawing │ ├── 1.png │ ├── basicdrawing.pro │ ├── image.qrc │ ├── main.cpp │ ├── renderarea.cpp │ ├── renderarea.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── ProgramFramework ├── DeviceControlDemo │ ├── DeviceControlDemo.pro │ ├── abstractsensor.cpp │ ├── abstractsensor.h │ ├── abstractthread.cpp │ ├── abstractthread.h │ ├── handletcpthread.cpp │ ├── handletcpthread.h │ ├── main.cpp │ ├── tcpsensor.cpp │ ├── tcpsensor.h │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── ProgramFramework.assets │ └── DeviceControlDemo.gif ├── ProgramFramework.md └── ProgramFramework.pro ├── QMDemo.pro ├── QMNetwork ├── NetInterface │ ├── NetInterface.pri │ ├── netproperty.cpp │ ├── netproperty.h │ └── netproperty.ui ├── NetWidget │ ├── NetWidget.pri │ ├── tcpclient.cpp │ ├── tcpclient.h │ ├── tcpclient.ui │ ├── tcpserver.cpp │ ├── tcpserver.h │ ├── tcpserver.ui │ ├── udpsocket.cpp │ ├── udpsocket.h │ └── udpsocket.ui ├── QMNetwork.assets │ ├── NetProperty.gif │ ├── TcpClient.gif │ └── TcpServer.gif ├── QMNetwork.md ├── QMNetwork.pro ├── SimpleNetWidget │ ├── SimpleNetWidget.pri │ ├── simpletcpclient.cpp │ ├── simpletcpclient.h │ ├── simpletcpclient.ui │ ├── simpletcpserver.cpp │ ├── simpletcpserver.h │ ├── simpletcpserver.ui │ ├── simpleudpgroup.cpp │ ├── simpleudpgroup.h │ ├── simpleudpgroup.ui │ ├── simpleudpsocket1.cpp │ ├── simpleudpsocket1.h │ ├── simpleudpsocket1.ui │ ├── simpleudpsocket2.cpp │ ├── simpleudpsocket2.h │ └── simpleudpsocket2.ui ├── main.cpp ├── widget.cpp ├── widget.h └── widget.ui ├── QSqlDemo ├── CachedTable │ ├── CachedTable.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QSql.assets │ ├── CachedTable.gif │ ├── RelationalTableModel.gif │ ├── SignIn-tuya.gif │ ├── SqlWidgetMapper.gif │ ├── TableModel2-tuya.gif │ └── image-20220518112255014.png ├── QSql.md ├── QSqlDemo.pro ├── RelationalTableModel │ ├── RelationalTableModel.pro │ └── main.cpp ├── SignIn │ ├── SignIn.pro │ ├── dialog.cpp │ ├── dialog.h │ ├── dialog.ui │ ├── main.cpp │ ├── userbackstage.cpp │ ├── userbackstage.h │ ├── userbackstage.ui │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── SqlWidgetMapper │ ├── SqlWidgetMapper.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── TableModel │ ├── TableModel.pro │ └── main.cpp └── TableModel2 │ ├── TableModel2.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QStyleDemo ├── IconDemo │ ├── IconDemo.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QStyleDemo.assets │ ├── QssDemo.gif │ ├── QssProperty-tuya.gif │ └── icon.gif ├── QStyleDemo.md ├── QStyleDemo.pro ├── QssDemo │ ├── QssDemo.pro │ ├── image │ │ ├── CheckBox_unchecked.png │ │ ├── Checkbox_Select.png │ │ ├── Checkbox_notAll.png │ │ ├── RadioBox_Unchecked.png │ │ ├── RadioBox_checked.png │ │ ├── bg.PNG │ │ ├── close.png │ │ ├── down.png │ │ ├── down_d.png │ │ ├── laft.png │ │ ├── plus.png │ │ ├── reduce.png │ │ ├── right.png │ │ ├── undock.png │ │ └── up.png │ ├── main.cpp │ ├── mainwindow.cpp │ ├── mainwindow.h │ ├── mainwindow.ui │ ├── style.css │ └── style.qrc └── QssProperty │ ├── QssProperty.pro │ ├── main.cpp │ ├── style.css │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QtChartsDemo ├── AreaChart │ ├── AreaChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── Audio │ ├── Audio.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ ├── widget.ui │ ├── xyseriesiodevice.cpp │ └── xyseriesiodevice.h ├── BarChart │ ├── BarChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── BoxPlotChart │ ├── BoxPlotChart.pro │ ├── acme.txt │ ├── data.qrc │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── CandlestickChart │ ├── CandlestickChart.pro │ ├── acme.txt │ ├── data.qrc │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── DonutChart │ ├── DonutChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── LineChart │ ├── LineChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PictureScroll │ ├── 1.jpg │ ├── 1.png │ ├── PictureScroll.pro │ ├── chartview.cpp │ ├── chartview.h │ ├── img.qrc │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PieChart │ ├── PieChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── PolarChart │ ├── PolarChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── QtCharts.assets │ ├── BarChart.gif │ ├── BoxPlotChart.gif │ ├── CandlestickChart.gif │ ├── PictureScroll-tuya.gif │ ├── ScatterChart.gif │ ├── image-20220425003919970.png │ ├── image-20220425003959893.png │ ├── image-20220428211944287.png │ ├── image-20220501141335238.png │ ├── image-20220501141454183.png │ ├── image-20220503224142003.png │ └── image-20220507213204801.png ├── QtCharts.md ├── QtChartsDemo.pro ├── ScatterChart │ ├── ScatterChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui └── SplineChart │ ├── SplineChart.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui ├── README.assets ├── Qt-5.12.12-green.png ├── Qt-5.12.12-green.svg ├── image-20220827211417219.png ├── 个人主页-CSDN-orange.png ├── 个人主页-CSDN-orange.svg ├── 国内站点-gitee-orange.png ├── 国内站点-gitee-orange.svg ├── 国外站点-github-brightgreen.png └── 国外站点-github-brightgreen.svg ├── README.md ├── Web ├── CefExamples │ ├── CefExamples.pro │ └── LoadWeb │ │ ├── LoadWeb.pro │ │ ├── hello.html │ │ ├── main.cpp │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui ├── JsonExamples │ ├── JsonExamples.pro │ └── QtJson │ │ ├── QtJson.pro │ │ ├── main.cpp │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui ├── QtWebExamples │ ├── QtWebExamples.pro │ ├── authorization │ │ ├── authorization.pro │ │ ├── main.cpp │ │ ├── mainwindow.cpp │ │ ├── mainwindow.h │ │ ├── rc.qrc │ │ └── video.html │ ├── channelDemo │ │ ├── channelDemo.pro │ │ ├── main.cpp │ │ ├── rc.qrc │ │ ├── web │ │ │ ├── main.css │ │ │ ├── main.js │ │ │ ├── qwebchannel.js │ │ │ └── webClient.html │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ ├── channelDemo2 │ │ ├── channelDemo2.pro │ │ ├── main.cpp │ │ ├── rc.qrc │ │ ├── web2 │ │ │ ├── main.css │ │ │ ├── main.js │ │ │ ├── qwebchannel.js │ │ │ └── webClient.html │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ ├── channelWebSocket │ │ ├── channelWebSocket.pro │ │ ├── main.cpp │ │ ├── swebchannel.cpp │ │ ├── swebchannel.h │ │ ├── web3 │ │ │ ├── channelClient.css │ │ │ ├── channelClient.html │ │ │ ├── channelClient.js │ │ │ └── qwebchannel.js │ │ ├── websockettransport.cpp │ │ ├── websockettransport.h │ │ ├── widget.cpp │ │ ├── widget.h │ │ └── widget.ui │ ├── minimal │ │ ├── hello.html │ │ ├── main.cpp │ │ ├── minimal.pro │ │ └── rc.qrc │ └── minimal2 │ │ ├── main.cpp │ │ └── minimal2.pro ├── Web.assets │ ├── channelDemo-tuya.gif │ ├── image-20221211210252527.png │ ├── image-20221214171041497.png │ ├── image-20221214171147965.png │ ├── image-20221215174224272.png │ ├── image-20221215175419479.png │ ├── image-20221216124021490.png │ ├── image-20221217210219249.png │ ├── image-20221217210336065.png │ ├── image-20221219154051957.png │ ├── image-20221219154652982.png │ ├── image-20230206155201961.png │ ├── image-20230206155232023.png │ ├── image-20230206155609104.png │ └── image-20230206155736344.png ├── Web.md ├── Web.pro └── WebSocketsExamples │ ├── ChatClient │ ├── ChatClient.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui │ ├── ChatClientHtml │ ├── ChatClientHtml.pro │ ├── html │ │ ├── chatClient.css │ │ ├── chatClient.html │ │ └── chatClient.js │ └── main.cpp │ ├── ChatServer │ ├── ChatServer.pro │ ├── main.cpp │ ├── widget.cpp │ ├── widget.h │ └── widget.ui │ └── WebSocketsExamples.pro └── XlsxDemo ├── QXlsx ├── CMakeLists.txt ├── QXlsx.pri ├── QXlsx.pro ├── header │ ├── xlsxabstractooxmlfile.h │ ├── xlsxabstractooxmlfile_p.h │ ├── xlsxabstractsheet.h │ ├── xlsxabstractsheet_p.h │ ├── xlsxcell.h │ ├── xlsxcell_p.h │ ├── xlsxcellformula.h │ ├── xlsxcellformula_p.h │ ├── xlsxcelllocation.h │ ├── xlsxcellrange.h │ ├── xlsxcellreference.h │ ├── xlsxchart.h │ ├── xlsxchart_p.h │ ├── xlsxchartsheet.h │ ├── xlsxchartsheet_p.h │ ├── xlsxcolor_p.h │ ├── xlsxconditionalformatting.h │ ├── xlsxconditionalformatting_p.h │ ├── xlsxcontenttypes_p.h │ ├── xlsxdatavalidation.h │ ├── xlsxdatavalidation_p.h │ ├── xlsxdatetype.h │ ├── xlsxdocpropsapp_p.h │ ├── xlsxdocpropscore_p.h │ ├── xlsxdocument.h │ ├── xlsxdocument_p.h │ ├── xlsxdrawing_p.h │ ├── xlsxdrawinganchor_p.h │ ├── xlsxformat.h │ ├── xlsxformat_p.h │ ├── xlsxglobal.h │ ├── xlsxmediafile_p.h │ ├── xlsxnumformatparser_p.h │ ├── xlsxrelationships_p.h │ ├── xlsxrichstring.h │ ├── xlsxrichstring_p.h │ ├── xlsxsharedstrings_p.h │ ├── xlsxsimpleooxmlfile_p.h │ ├── xlsxstyles_p.h │ ├── xlsxtheme_p.h │ ├── xlsxutility_p.h │ ├── xlsxworkbook.h │ ├── xlsxworkbook_p.h │ ├── xlsxworksheet.h │ ├── xlsxworksheet_p.h │ ├── xlsxzipreader_p.h │ └── xlsxzipwriter_p.h └── source │ ├── xlsxabstractooxmlfile.cpp │ ├── xlsxabstractsheet.cpp │ ├── xlsxcell.cpp │ ├── xlsxcellformula.cpp │ ├── xlsxcelllocation.cpp │ ├── xlsxcellrange.cpp │ ├── xlsxcellreference.cpp │ ├── xlsxchart.cpp │ ├── xlsxchartsheet.cpp │ ├── xlsxcolor.cpp │ ├── xlsxconditionalformatting.cpp │ ├── xlsxcontenttypes.cpp │ ├── xlsxdatavalidation.cpp │ ├── xlsxdatetype.cpp │ ├── xlsxdocpropsapp.cpp │ ├── xlsxdocpropscore.cpp │ ├── xlsxdocument.cpp │ ├── xlsxdrawing.cpp │ ├── xlsxdrawinganchor.cpp │ ├── xlsxformat.cpp │ ├── xlsxmediafile.cpp │ ├── xlsxnumformatparser.cpp │ ├── xlsxrelationships.cpp │ ├── xlsxrichstring.cpp │ ├── xlsxsharedstrings.cpp │ ├── xlsxsimpleooxmlfile.cpp │ ├── xlsxstyles.cpp │ ├── xlsxtheme.cpp │ ├── xlsxutility.cpp │ ├── xlsxworkbook.cpp │ ├── xlsxworksheet.cpp │ ├── xlsxzipreader.cpp │ └── xlsxzipwriter.cpp ├── TestXlsx ├── Interface.h ├── TestXlsx.pri ├── test1.cpp ├── test1.h ├── test1.ui ├── test2.cpp ├── test2.h ├── test2.ui ├── test3.cpp ├── test3.h ├── test3.ui ├── test4.cpp ├── test4.h ├── test4.ui ├── test5.cpp ├── test5.h ├── test5.ui ├── test6.cpp ├── test6.h ├── test6.ui ├── test7.cpp ├── test7.h └── test7.ui ├── XlsxDemo.assets ├── image-20220629154430927.png ├── image-20220629154520501.png ├── image-20220629154549163.png ├── image-20220712163106069.png ├── image-20220712163125370.png ├── qxlsx1.gif ├── shee.gif ├── state.gif ├── test5-tuya.gif └── test6.gif ├── XlsxDemo.md ├── XlsxDemo.pro ├── appendix.qrc ├── image ├── C++.PNG └── Qt.PNG ├── main.cpp ├── widget.cpp ├── widget.h └── widget.ui /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.so.* 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | object_script.*.Release 15 | object_script.*.Debug 16 | *_plugin_import.cpp 17 | /.qmake.cache 18 | /.qmake.stash 19 | *.pro.user 20 | *.pro.user.* 21 | *.qbs.user 22 | *.qbs.user.* 23 | *.moc 24 | moc_*.cpp 25 | moc_*.h 26 | qrc_*.cpp 27 | ui_*.h 28 | *.qmlc 29 | *.jsc 30 | Makefile* 31 | *build-* 32 | *.qm 33 | *.prl 34 | 35 | # Qt unit tests 36 | target_wrapper.* 37 | 38 | # QtCreator 39 | *.autosave 40 | 41 | # QtCreator Qml 42 | *.qmlproject.user 43 | *.qmlproject.user.* 44 | 45 | # QtCreator CMake 46 | CMakeLists.txt.user* 47 | 48 | # QtCreator 4.8< compilation database 49 | compile_commands.json 50 | 51 | # QtCreator local machine specific files for imported projects 52 | *creator.user* 53 | 54 | bin*/ 55 | build/ 56 | !FunctionalModule/ScanFile/lib/* -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/UseQThread1-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/UseQThread1-tuya.gif -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/UseQThread2-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/UseQThread2-tuya.gif -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230218120351892.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230218120351892.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230218120716966.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230218120716966.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230224151913976.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230224151913976.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230226215928039.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230226215928039.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230309210116047.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230309210116047.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/image-20230312113522409.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/image-20230312113522409.png -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.assets/ioThread-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ConcurrentExamples/ConcurrentExamples.assets/ioThread-tuya.gif -------------------------------------------------------------------------------- /ConcurrentExamples/ConcurrentExamples.pro: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------- 2 | # @功能: Qt线程和并发编程示例 3 | # @编译器: Desktop Qt 5.12.5 MSVC2017 64bit(也支持其它编译器) 4 | # @Qt IDE: D:/Qt/Qt5.12.5/Tools/QtCreator/share/qtcreator 5 | # 6 | # @开发者 mhf 7 | # @邮箱 1603291350@qq.com 8 | # @时间 2023-01-15 20:04:15 9 | # @备注 10 | #--------------------------------------------------------------------------------------- 11 | TEMPLATE = subdirs 12 | 13 | SUBDIRS += UseQThread1 # Qt通过【实例化】QThread,使用moveToThread将QObject子类槽函数在子线程中执行 14 | SUBDIRS += UseQThread2 # Qt通过子类化,继承QThread,重写run实现子线程 15 | SUBDIRS += UseQThreadPool # Qt使用线程池QThreadPool示例 16 | SUBDIRS += UseConcurrent # Qt Concurent API使用示例 17 | SUBDIRS += IOThread # 在QT子线程中操作IO对象,包括QAbstractSocket、QFile、QSerialPort等 18 | -------------------------------------------------------------------------------- /ConcurrentExamples/IOThread/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | QTextCodec *codec = QTextCodec::codecForName("GBK"); 10 | QTextCodec::setCodecForLocale(codec); 11 | Widget w; 12 | w.show(); 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /ConcurrentExamples/IOThread/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "iothread.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(bool checked); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | void on_readyRead(QByteArray data); // 返回数据 26 | 27 | private: 28 | Ui::Widget *ui; 29 | IOThread* m_io = nullptr; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseConcurrent/Map/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseConcurrent/Mapped/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseConcurrent/Mapped/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_resultReadyAt(int resultIndex); 21 | void on_pushButton_clicked(); 22 | 23 | private: 24 | Ui::Widget *ui; 25 | QFutureWatcher m_futureWatcher; 26 | QList m_maxs; 27 | }; 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseConcurrent/RunFunction/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseConcurrent/RunFunction/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | static void test3(); 20 | void test4(); 21 | 22 | private slots: 23 | void on_pushButton_clicked(); 24 | 25 | void on_pushButton_2_clicked(); 26 | 27 | void on_pushButton_3_clicked(); 28 | 29 | void on_pushButton_4_clicked(); 30 | 31 | private: 32 | Ui::Widget *ui; 33 | QThreadPool m_pool; 34 | }; 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "work1.h" 6 | #include "work2.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_pushButton_clicked(); 22 | 23 | void on_pushButton_2_clicked(); 24 | 25 | private: 26 | Ui::Widget *ui; 27 | Work1* m_work1 = nullptr; 28 | Work2* m_work2 = nullptr; 29 | QThread* m_thread = nullptr; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/work1.cpp: -------------------------------------------------------------------------------- 1 | #include "work1.h" 2 | 3 | Work1::Work1(QObject *parent) : QObject(parent) 4 | { 5 | // 在内部创建子线程 6 | m_thread = new WorkThread(); // 这里通过继承QThread验证在程序退出时是否会释放m_thread 7 | m_thread->start(); 8 | this->moveToThread(m_thread); 9 | connect(this, &Work1::start, this, &Work1::delayCount); 10 | } 11 | 12 | Work1::~Work1() 13 | { 14 | m_thread->quit(); // 告诉线程的事件循环退出 15 | m_thread->wait(); // 等待线程执行完成(默认不会超时,一直等到线程退出) 16 | // qDebug() << m_thread->wait(1000); // 等待1000毫秒,如果线程没有退出则超时,直接终止线程,返回false 17 | // delete m_thread; // 由于m_thread没有指定父对象,所以需要自己释放 18 | // m_thread = nullptr; 19 | qDebug() << "析构Work1"; 20 | } 21 | 22 | void Work1::delayCount() 23 | { 24 | emit updateData(10); 25 | QThread::sleep(5); // 延时5秒,模拟耗时操作 26 | emit updateData(100); 27 | } 28 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/work1.h: -------------------------------------------------------------------------------- 1 | #ifndef WORK_H 2 | #define WORK_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class WorkThread: public QThread 10 | { 11 | Q_OBJECT 12 | public: 13 | 14 | explicit WorkThread(QObject *parent = nullptr) 15 | { 16 | qDebug() << "创建线程"; 17 | } 18 | ~WorkThread() 19 | { 20 | qDebug() << "析构线程"; 21 | } 22 | }; 23 | 24 | class Work1 : public QObject 25 | { 26 | Q_OBJECT 27 | public: 28 | explicit Work1(QObject *parent = nullptr); 29 | ~Work1(); 30 | 31 | signals: 32 | void start(); 33 | void updateData(int num); 34 | 35 | public slots: 36 | void delayCount(); 37 | 38 | private: 39 | WorkThread* m_thread = nullptr; 40 | }; 41 | 42 | #endif // WORK_H 43 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/work2.cpp: -------------------------------------------------------------------------------- 1 | #include "work2.h" 2 | 3 | #include 4 | #include 5 | 6 | Work2::Work2(QObject *parent) : QObject(parent) 7 | { 8 | connect(this, &Work2::start, this, &Work2::delayCount); 9 | } 10 | 11 | Work2::~Work2() 12 | { 13 | qDebug() << "析构Work2"; 14 | } 15 | 16 | void Work2::delayCount() 17 | { 18 | emit updateData(10); 19 | QThread::sleep(5); // 延时5秒,模拟耗时操作 20 | emit updateData(100); 21 | } 22 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread1/work2.h: -------------------------------------------------------------------------------- 1 | #ifndef WORK2_H 2 | #define WORK2_H 3 | 4 | #include 5 | 6 | class Work2 : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Work2(QObject *parent = nullptr); 11 | ~Work2(); 12 | 13 | signals: 14 | void start(); 15 | void updateData(int num); 16 | 17 | public slots: 18 | void delayCount(); 19 | 20 | }; 21 | 22 | #endif // WORK2_H 23 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread2/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 | this->setWindowTitle(QString("Qt通过子类化,继承QThread,重写run实现子线程--V%1").arg(APP_VERSION)); 11 | 12 | m_workThread = new WorkThread(this); 13 | connect(m_workThread, &WorkThread::updateData, ui->lcdNumber, QOverload::of(&QLCDNumber::display)); 14 | } 15 | 16 | Widget::~Widget() 17 | { 18 | // m_workThread->terminate(); // 直接终止线程,此功能很危险,不鼓励使用 19 | delete ui; 20 | } 21 | 22 | 23 | void Widget::on_pushButton_clicked() 24 | { 25 | m_workThread->start(); 26 | } 27 | 28 | void Widget::on_pushButton_2_clicked() 29 | { 30 | m_workThread->abort(); 31 | } 32 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread2/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "workthread.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | 22 | void on_pushButton_2_clicked(); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | WorkThread* m_workThread = nullptr; 27 | }; 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread2/workthread.cpp: -------------------------------------------------------------------------------- 1 | #include "workthread.h" 2 | #include 3 | WorkThread::WorkThread(QObject *parent) : QThread(parent) 4 | { 5 | } 6 | 7 | WorkThread::~WorkThread() 8 | { 9 | qDebug() << "析构线程"; 10 | m_abort = true; // 设置将线程退出标志 11 | this->wait(); // 等待线程退出 12 | } 13 | 14 | /** 15 | * @brief 退出线程 16 | */ 17 | void WorkThread::abort() 18 | { 19 | m_abort = true; 20 | } 21 | 22 | void WorkThread::run() 23 | { 24 | qDebug() << "开始线程"; 25 | m_abort = false; 26 | int i = 0; 27 | forever 28 | { 29 | QThread::sleep(1); 30 | emit updateData(++i); 31 | 32 | // 退出线程 33 | if(m_abort) break; 34 | } 35 | 36 | qDebug() << "退出线程"; 37 | } 38 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThread2/workthread.h: -------------------------------------------------------------------------------- 1 | #ifndef WORKTHREAD_H 2 | #define WORKTHREAD_H 3 | 4 | #include 5 | 6 | class WorkThread : public QThread 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit WorkThread(QObject *parent = nullptr); 11 | ~WorkThread() override; 12 | 13 | signals: 14 | void updateData(int num); 15 | 16 | public slots: 17 | void abort(); 18 | 19 | protected: 20 | void run() override; 21 | 22 | private: 23 | bool m_abort = false; 24 | }; 25 | 26 | #endif // WORKTHREAD_H 27 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThreadPool/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ConcurrentExamples/UseQThreadPool/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_pushButton_clicked(); 20 | 21 | void on_pushButton_2_clicked(); 22 | 23 | void on_pushButton_3_clicked(); 24 | 25 | void on_pushButton_4_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | }; 30 | #endif // WIDGET_H 31 | -------------------------------------------------------------------------------- /Experience/Experience.assets/image-20230107153044329.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Experience/Experience.assets/image-20230107153044329.png -------------------------------------------------------------------------------- /Experience/Experience.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += UsePath # Qt使用路径的方式和注意事项 4 | -------------------------------------------------------------------------------- /Experience/UsePath/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Experience/UsePath/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | 20 | private: 21 | Ui::Widget *ui; 22 | }; 23 | #endif // WIDGET_H 24 | -------------------------------------------------------------------------------- /FFmpegDemo/AVIOReading/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | Widget w; 11 | w.show(); 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /FFmpegDemo/DecodeAudio/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | Widget w; 11 | w.show(); 12 | return a.exec(); 13 | } 14 | -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/AVIOReading-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/AVIOReading-tuya.gif -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/DecodeAudio.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/DecodeAudio.gif -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/VideoCamera1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/VideoCamera1.gif -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/VideoCamera2-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/VideoCamera2-tuya.gif -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/VideoPlay-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/VideoPlay-tuya.gif -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/VideoPlayHW-tuya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/VideoPlayHW-tuya.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20221015204308041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20221015204308041.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20221017232820037.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20221017232820037.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20221020192642223.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20221020192642223.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20221024094954935.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20221024094954935.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20221027235118681.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20221027235118681.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20230101133211140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20230101133211140.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20230104155424623.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20230104155424623.png -------------------------------------------------------------------------------- /FFmpegDemo/FFmpegDemo.assets/image-20240415223552799.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FFmpegDemo/FFmpegDemo.assets/image-20240415223552799.png -------------------------------------------------------------------------------- /FFmpegDemo/Screencap/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/Screencap/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "readthread.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_open_clicked(); 22 | void on_playState(ReadThread::PlayState state); 23 | 24 | bool setSavePath(); 25 | void on_timeout(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | ReadThread* m_readThread = nullptr; 30 | QTimer m_timer; 31 | }; 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera1/fragment.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 TexCord; // 纹理坐标 3 | uniform sampler2D tex_y; 4 | uniform sampler2D tex_u; 5 | uniform sampler2D tex_v; 6 | 7 | void main() 8 | { 9 | vec3 yuv; 10 | vec3 rgb; 11 | 12 | // YUV转RGB 13 | yuv.x = texture2D(tex_y, TexCord).r; 14 | yuv.y = texture2D(tex_u, TexCord).r-0.5; 15 | yuv.z = texture2D(tex_v, TexCord).r-0.5; 16 | 17 | rgb = mat3(1.0, 1.0, 1.0, 18 | 0.0, -0.39465, 2.03211, 19 | 1.13983, -0.58060, 0.0) * yuv; 20 | gl_FragColor = vec4(rgb, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera1/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera1/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0); // 图像坐标和OpenGL坐标Y轴相反, 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera1/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_open_clicked(); 22 | 23 | void on_playState(ReadThread::PlayState state); 24 | 25 | private: 26 | Ui::Widget *ui; 27 | 28 | PlayImage* playImage = nullptr; 29 | ReadThread* m_readThread = nullptr; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera2/fragment.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 TexCord; // 纹理坐标 3 | uniform sampler2D tex_y; 4 | uniform sampler2D tex_u; 5 | uniform sampler2D tex_v; 6 | 7 | void main() 8 | { 9 | vec3 yuv; 10 | vec3 rgb; 11 | 12 | // YUV转RGB 13 | yuv.x = texture2D(tex_y, TexCord).r; 14 | yuv.y = texture2D(tex_u, TexCord).r-0.5; 15 | yuv.z = texture2D(tex_v, TexCord).r-0.5; 16 | 17 | rgb = mat3(1.0, 1.0, 1.0, 18 | 0.0, -0.39465, 2.03211, 19 | 1.13983, -0.58060, 0.0) * yuv; 20 | gl_FragColor = vec4(rgb, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera2/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera2/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0); // 图像坐标和OpenGL坐标Y轴相反, 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera2/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_open_clicked(); 22 | 23 | void on_playState(ReadThread::PlayState state); 24 | 25 | void on_but_save_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | 30 | PlayImage* playImage = nullptr; 31 | ReadThread* m_readThread = nullptr; 32 | }; 33 | #endif // WIDGET_H 34 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera3/fragment.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 TexCord; // 纹理坐标 3 | uniform sampler2D tex_y; 4 | uniform sampler2D tex_u; 5 | uniform sampler2D tex_v; 6 | 7 | void main() 8 | { 9 | vec3 yuv; 10 | vec3 rgb; 11 | 12 | // YUV转RGB 13 | yuv.x = texture2D(tex_y, TexCord).r; 14 | yuv.y = texture2D(tex_u, TexCord).r-0.5; 15 | yuv.z = texture2D(tex_v, TexCord).r-0.5; 16 | 17 | rgb = mat3(1.0, 1.0, 1.0, 18 | 0.0, -0.39465, 2.03211, 19 | 1.13983, -0.58060, 0.0) * yuv; 20 | gl_FragColor = vec4(rgb, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera3/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera3/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera3/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0); // 图像坐标和OpenGL坐标Y轴相反, 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoCamera3/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include "playimage.h" 5 | #include "readthread.h" 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | 10 | namespace Ui { 11 | class Widget; 12 | } 13 | 14 | QT_END_NAMESPACE 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | Widget(QWidget* parent = nullptr); 22 | ~Widget(); 23 | 24 | private slots: 25 | void on_but_open_clicked(); 26 | 27 | void on_playState(ReadThread::PlayState state); 28 | 29 | private: 30 | Ui::Widget* ui; 31 | 32 | PlayImage* playImage = nullptr; 33 | ReadThread* m_readThread = nullptr; 34 | }; 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlay/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlay/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_but_file_clicked(); 21 | 22 | void on_but_open_clicked(); 23 | 24 | void on_but_pause_clicked(); 25 | 26 | void on_playState(ReadThread::PlayState state); 27 | 28 | private: 29 | Ui::Widget *ui; 30 | 31 | ReadThread* m_readThread = nullptr; 32 | }; 33 | #endif // WIDGET_H 34 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL1/fragment.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCord; // 纹理坐标 4 | uniform sampler2D texture; // 纹理采样器 5 | void main() 6 | { 7 | FragColor = texture2D(texture, TexCord); // 采样纹理函数 8 | } 9 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL1/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL1/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL1/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos, 1.0); 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL1/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_file_clicked(); 22 | 23 | void on_but_open_clicked(); 24 | 25 | void on_but_pause_clicked(); 26 | 27 | void on_playState(ReadThread::PlayState state); 28 | 29 | private: 30 | Ui::Widget *ui; 31 | 32 | PlayImage* playImage = nullptr; 33 | ReadThread* m_readThread = nullptr; 34 | }; 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL2/fragment.fsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 TexCord; // 纹理坐标 3 | uniform sampler2D tex_y; 4 | uniform sampler2D tex_u; 5 | uniform sampler2D tex_v; 6 | 7 | void main() 8 | { 9 | vec3 yuv; 10 | vec3 rgb; 11 | 12 | // YUV转RGB 13 | yuv.x = texture2D(tex_y, TexCord).r; 14 | yuv.y = texture2D(tex_u, TexCord).r-0.5; 15 | yuv.z = texture2D(tex_v, TexCord).r-0.5; 16 | 17 | rgb = mat3(1.0, 1.0, 1.0, 18 | 0.0, -0.39465, 2.03211, 19 | 1.13983, -0.58060, 0.0) * yuv; 20 | gl_FragColor = vec4(rgb, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL2/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL2/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0); // 图像坐标和OpenGL坐标Y轴相反, 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayGL2/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_file_clicked(); 22 | 23 | void on_but_open_clicked(); 24 | 25 | void on_but_pause_clicked(); 26 | 27 | void on_playState(ReadThread::PlayState state); 28 | 29 | private: 30 | Ui::Widget *ui; 31 | 32 | PlayImage* playImage = nullptr; 33 | ReadThread* m_readThread = nullptr; 34 | }; 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHW/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHW/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_but_file_clicked(); 22 | 23 | void on_but_open_clicked(); 24 | 25 | void on_but_pause_clicked(); 26 | 27 | void on_playState(ReadThread::PlayState state); 28 | 29 | private: 30 | Ui::Widget *ui; 31 | 32 | ReadThread* m_readThread = nullptr; 33 | QList m_readThreads; 34 | QList m_playImages; 35 | }; 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHWGL/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHWGL/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragment.fsh 4 | vertex.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHWGL/vertex.vsh: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCord; 4 | out vec2 TexCord; // 纹理坐标 5 | void main() 6 | { 7 | gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0); // 图像坐标和OpenGL坐标Y轴相反, 8 | TexCord = aTexCord; 9 | } 10 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlayHWGL/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | #include "playimage.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_but_file_clicked(); 21 | 22 | void on_but_open_clicked(); 23 | 24 | void on_but_pause_clicked(); 25 | 26 | void on_playState(ReadThread::PlayState state); 27 | 28 | void on_check_HW_clicked(bool checked); 29 | 30 | private: 31 | Ui::Widget *ui; 32 | 33 | PlayImage* playImage = nullptr; 34 | ReadThread* m_readThread = nullptr; 35 | }; 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlaySave/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FFmpegDemo/VideoPlaySave/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "readthread.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_but_file_clicked(); 21 | 22 | void on_but_open_clicked(); 23 | 24 | void on_but_pause_clicked(); 25 | 26 | void on_playState(ReadThread::PlayState state); 27 | 28 | private: 29 | Ui::Widget *ui; 30 | 31 | ReadThread* m_readThread = nullptr; 32 | }; 33 | #endif // WIDGET_H 34 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/head.h: -------------------------------------------------------------------------------- 1 | #ifndef HEAD_H 2 | #define HEAD_H 3 | 4 | //MSVC编译器 5 | #ifdef _MSC_VER 6 | #if _MSC_VER >=1600 // VC2010 以上 7 | //#pragma execution_character_set("utf-8") 8 | #endif 9 | #endif 10 | 11 | 12 | #endif // HEAD_H 13 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/mousekeytest.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 mousekeytest.h 3 | * @功能 鼠标、键盘热插拔监测 4 | * 5 | * @开发者 (作者) 6 | * @时间 2021/12/04 7 | * @备注 8 | *****************************************************************************/ 9 | #ifndef MOUSEKEYTEST_H 10 | #define MOUSEKEYTEST_H 11 | 12 | #include 13 | 14 | namespace Ui { 15 | class MouseKeyTest; 16 | } 17 | 18 | class MouseKeyTest : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit MouseKeyTest(QWidget *parent = nullptr); 24 | ~MouseKeyTest(); 25 | 26 | private: 27 | bool nativeEvent(const QByteArray &eventType, void *message, long *result); 28 | void registerGUID(); 29 | 30 | private: 31 | Ui::MouseKeyTest *ui; 32 | }; 33 | 34 | #endif // MOUSEKEYTEST_H 35 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/serialportstatus.cpp: -------------------------------------------------------------------------------- 1 | #include "serialportstatus.h" 2 | 3 | SerialPortStatus::SerialPortStatus(QObject *parent) : QObject(parent) 4 | { 5 | 6 | } 7 | 8 | bool SerialPortStatus::nativeEventFilter(const QByteArray &eventType, void *message, long *result) 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include "comchange.h" 5 | 6 | Widget::Widget(QWidget *parent) 7 | : QWidget(parent) 8 | , ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | 12 | this->setWindowTitle(QString("串口、鼠标、键盘热插拔监测demo - V%1").arg(APP_VERSION)); 13 | m_port = new PortTest(); 14 | m_mouseKey = new MouseKeyTest(); 15 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 16 | this->resize(500, 300); 17 | } 18 | 19 | Widget::~Widget() 20 | { 21 | delete ui; 22 | } 23 | 24 | void Widget::on_but_port_clicked() 25 | { 26 | m_port->show(); 27 | } 28 | 29 | void Widget::on_pushButton_2_clicked() 30 | { 31 | m_mouseKey->show(); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /FunctionalModule/DeviceManagement/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "porttest.h" 6 | #include "mousekeytest.h" 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | 21 | private slots: 22 | void on_but_port_clicked(); 23 | 24 | void on_pushButton_2_clicked(); 25 | 26 | private: 27 | Ui::Widget *ui; 28 | PortTest* m_port = nullptr; 29 | MouseKeyTest* m_mouseKey = nullptr; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/Dump.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/Dump.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/MouseKeyEvent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/MouseKeyEvent.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/NtpClient.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/NtpClient.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/QLog.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/QLog.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/QMPlayer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/QMPlayer.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/QMWidget.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/QMWidget.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/image-20220408223533219.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/image-20220408223533219.png -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/image-20221121125725058.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/image-20221121125725058.png -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/image-20240502211734717.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/image-20240502211734717.png -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/log.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/log.PNG -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/mouseEvent-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/mouseEvent-tuya.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/windowRect1-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/windowRect1-tuya.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/windowRect2-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/windowRect2-tuya.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/串口状态检测.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/串口状态检测.gif -------------------------------------------------------------------------------- /FunctionalModule/FunctionalModule.assets/鼠标键盘热插拔监测.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/FunctionalModule.assets/鼠标键盘热插拔监测.gif -------------------------------------------------------------------------------- /FunctionalModule/MouseKeyEvent/GlobalMouseKey/globalkeyevent.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALKEYEVENT_H 2 | #define GLOBALKEYEVENT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * 全局鼠标事件单例信号类 10 | */ 11 | class GlobalKeyEvent : public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | static GlobalKeyEvent* getInstance() 16 | { 17 | static GlobalKeyEvent keyEvent; 18 | return &keyEvent; 19 | } 20 | 21 | static bool installKeyEvent(); // 安装全局键盘事件监听器 22 | static bool removeKeyEvent(); // 卸载全局键盘事件监听器 23 | 24 | signals: 25 | void keyEvent(QSharedPointer event); 26 | 27 | private: 28 | GlobalKeyEvent() {} 29 | }; 30 | 31 | #endif // GLOBALKEYEVENT_H 32 | -------------------------------------------------------------------------------- /FunctionalModule/MouseKeyEvent/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /FunctionalModule/MouseKeyEvent/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | 10 | namespace Ui { 11 | class Widget; 12 | } 13 | 14 | QT_END_NAMESPACE 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | public: 20 | Widget(QWidget* parent = nullptr); 21 | ~Widget(); 22 | 23 | protected: 24 | void on_mouseEvent(QSharedPointer event); 25 | void on_wheelEvent(QSharedPointer event); 26 | void on_keyEvent(QSharedPointer event); 27 | private slots: 28 | void on_but_mouseI_clicked(); 29 | 30 | void on_but_mouser_clicked(); 31 | 32 | void on_but_keyI_clicked(); 33 | 34 | void on_but_KeyR_clicked(); 35 | 36 | private: 37 | Ui::Widget* ui; 38 | }; 39 | 40 | #endif // WIDGET_H 41 | -------------------------------------------------------------------------------- /FunctionalModule/NtpClient/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/NtpClient/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | #include 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) 7 | : QWidget(parent) 8 | , ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | this->setWindowTitle(QString("NTP时间同步客户端 - V%1").arg(APP_VERSION)); 12 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 13 | 14 | connect(&m_ntpClient, &NtpClient::updateData, ui->textEdit, &QTextEdit::append); 15 | 16 | 17 | } 18 | 19 | Widget::~Widget() 20 | { 21 | delete ui; 22 | } 23 | 24 | 25 | void Widget::on_but_getTime_clicked() 26 | { 27 | m_ntpClient.getTime(); 28 | // QThread::msleep(100); 29 | // m_ntpClient.getTime(); 30 | } 31 | 32 | void Widget::on_but_connect_clicked() 33 | { 34 | m_ntpClient.connectServer(ui->com_address->currentText()); 35 | } 36 | -------------------------------------------------------------------------------- /FunctionalModule/NtpClient/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "ntpclient.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_but_getTime_clicked(); 21 | 22 | void on_but_connect_clicked(); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | 27 | NtpClient m_ntpClient; 28 | }; 29 | #endif // WIDGET_H 30 | -------------------------------------------------------------------------------- /FunctionalModule/QLog/QLog/head.h: -------------------------------------------------------------------------------- 1 | #ifndef HEAD_H 2 | #define HEAD_H 3 | 4 | //MSVC编译器 5 | #ifdef _MSC_VER 6 | #if _MSC_VER >=1600 // VC2010 以上 7 | //#pragma execution_character_set("utf-8") 8 | #endif 9 | #endif 10 | 11 | 12 | #endif // HEAD_H 13 | -------------------------------------------------------------------------------- /FunctionalModule/QLog/QLog/logsavebase.cpp: -------------------------------------------------------------------------------- 1 | #include "logsavebase.h" 2 | 3 | #include "loginput.h" 4 | #include 5 | #include 6 | #include 7 | 8 | LogSaveBase::LogSaveBase(QObject* parent) 9 | : QObject(parent) 10 | { 11 | // 将数据保存放入线程中 12 | m_thread = new QThread; 13 | this->moveToThread(m_thread); 14 | m_thread->start(); 15 | 16 | QDir dir; 17 | if (!dir.exists(LOG_PATH)) 18 | { 19 | dir.mkpath(LOG_PATH); 20 | } 21 | connect(LogInput::getInstance(), &LogInput::logData, this, &LogSaveBase::on_logData, Qt::QueuedConnection); 22 | } 23 | 24 | LogSaveBase::~LogSaveBase() 25 | { 26 | m_thread->quit(); 27 | m_thread->wait(); 28 | disconnect(LogInput::getInstance(), &LogInput::logData, this, &LogSaveBase::on_logData); 29 | } 30 | 31 | LogSaveBase* LogSaveBase::m_logSave = nullptr; 32 | -------------------------------------------------------------------------------- /FunctionalModule/QLog/QLog/logwidgetbase.cpp: -------------------------------------------------------------------------------- 1 | #include "logwidgetbase.h" 2 | #include "loginput.h" 3 | 4 | LogWidgetBase::LogWidgetBase(QWidget *parent) : QWidget(parent) 5 | { 6 | LogSaveTxt::initLog(); // 初始化日志保存功能 7 | connect(LogInput::getInstance(), &LogInput::logData, this, &LogWidgetBase::on_logData, Qt::QueuedConnection); 8 | } 9 | -------------------------------------------------------------------------------- /FunctionalModule/QLog/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include "logsavetxt.h" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | LogSaveTxt::initLog(); // 初始化日志保存功能,如果想保存程序启动的所有日志就加上这一行,如果通过提升为LogWidgetText则在这个控件初始化之前的日志不会保存 10 | Widget w; 11 | w.show(); 12 | 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /FunctionalModule/QLog/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | namespace Ui { 10 | class Widget; 11 | } 12 | 13 | QT_END_NAMESPACE 14 | 15 | class Widget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | Widget(QWidget* parent = nullptr); 21 | ~Widget(); 22 | 23 | private slots: 24 | 25 | void on_timer(); 26 | 27 | void on_com_FileType_activated(int index); 28 | 29 | void on_but_thread_clicked(); 30 | 31 | private: 32 | bool m_quit = false; // 退出线程 33 | Ui::Widget* ui; 34 | QTimer* m_timer; 35 | }; 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Module/Module.pri: -------------------------------------------------------------------------------- 1 | FORMS += \ 2 | $$PWD/controlbar.ui \ 3 | $$PWD/sidebar.ui \ 4 | $$PWD/titlebar.ui 5 | 6 | HEADERS += \ 7 | $$PWD/controlbar.h \ # 播放控制栏 8 | $$PWD/sidebar.h \ # 侧边栏 9 | $$PWD/slidervideo.h \ 10 | $$PWD/titlebar.h # 自定义标题栏 11 | 12 | SOURCES += \ 13 | $$PWD/controlbar.cpp \ 14 | $$PWD/sidebar.cpp \ 15 | $$PWD/slidervideo.cpp \ 16 | $$PWD/titlebar.cpp 17 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Module/sidebar.cpp: -------------------------------------------------------------------------------- 1 | #include "sidebar.h" 2 | #include "ui_sidebar.h" 3 | #include 4 | #include 5 | 6 | Sidebar::Sidebar(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::Sidebar) 9 | { 10 | ui->setupUi(this); 11 | } 12 | 13 | Sidebar::~Sidebar() 14 | { 15 | delete ui; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Module/sidebar.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 sidebar.h 3 | * @功能 自定义侧边栏,用于显示播放列表 4 | * 1、支持动画打开关闭功能; 5 | * 6 | * @开发者 mhf 7 | * @邮箱 1603291350@qq.com 8 | * @时间 2022/03/27 9 | * @备注 10 | *****************************************************************************/ 11 | #ifndef SIDEBAR_H 12 | #define SIDEBAR_H 13 | 14 | #include 15 | 16 | 17 | namespace Ui { 18 | class Sidebar; 19 | } 20 | 21 | class Sidebar : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit Sidebar(QWidget *parent = nullptr); 27 | ~Sidebar(); 28 | 29 | protected: 30 | void on_finished(); 31 | 32 | private: 33 | Ui::Sidebar *ui; 34 | 35 | }; 36 | 37 | #endif // SIDEBAR_H 38 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Module/slidervideo.cpp: -------------------------------------------------------------------------------- 1 | #include "slidervideo.h" 2 | 3 | #include 4 | #include 5 | 6 | SliderVideo::SliderVideo(QWidget* parent) 7 | : QSlider(parent) 8 | {} 9 | 10 | void SliderVideo::mousePressEvent(QMouseEvent* event) 11 | { 12 | if (event->button() == Qt::LeftButton || event->button() == Qt::MiddleButton) // 右键或中键点击时跳转到鼠标点击位置 13 | { 14 | int value = QStyle::sliderValueFromPosition(this->minimum(), this->maximum(), event->pos().x(), this->width()); 15 | this->setValue(value); 16 | } 17 | QSlider::mousePressEvent(event); 18 | } 19 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Module/slidervideo.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 slidervideo.h 3 | * @功能 自定义视频播放进度条 4 | * 5 | * @开发者 mhf 6 | * @邮箱 1603291350@qq.com 7 | * @时间 2022/04/03 8 | * @备注 9 | *****************************************************************************/ 10 | #ifndef SLIDERVIDEO_H 11 | #define SLIDERVIDEO_H 12 | 13 | #include 14 | 15 | class SliderVideo : public QSlider 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit SliderVideo(QWidget *parent = nullptr); 20 | 21 | signals: 22 | 23 | protected: 24 | void mousePressEvent(QMouseEvent *event) override; 25 | 26 | private: 27 | }; 28 | 29 | #endif // SLIDERVIDEO_H 30 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/Closevolume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/Closevolume.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/close.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/max.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/min.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/next.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/next_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/next_hover.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/play.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/play_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/play_hover.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/previous.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/previous_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/previous_hover.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/restore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/restore.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/setup.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/stop.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/stop_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/stop_hover.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/Style/image/volume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMPlayer/Style/image/volume.png -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/WidgetBase/WidgetBase.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/mwidgetbase.h 3 | 4 | SOURCES += \ 5 | $$PWD/mwidgetbase.cpp 6 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/QMPlayer/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Style/main.css 4 | Style/image/close.png 5 | Style/image/Closevolume.png 6 | Style/image/max.png 7 | Style/image/min.png 8 | Style/image/next.png 9 | Style/image/next_hover.png 10 | Style/image/play.png 11 | Style/image/play_hover.png 12 | Style/image/previous.png 13 | Style/image/previous_hover.png 14 | Style/image/restore.png 15 | Style/image/setup.png 16 | Style/image/stop.png 17 | Style/image/stop_hover.png 18 | Style/image/volume.png 19 | 20 | 21 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Module/Module.pri: -------------------------------------------------------------------------------- 1 | FORMS += \ 2 | $$PWD/titlebar.ui 3 | 4 | HEADERS += \ 5 | $$PWD/titlebar.h # 自定义窗口标题栏组件 6 | 7 | SOURCES += \ 8 | $$PWD/titlebar.cpp 9 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Module/controlbar.cpp: -------------------------------------------------------------------------------- 1 | #include "controlbar.h" 2 | #include "ui_controlbar.h" 3 | 4 | ControlBar::ControlBar(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::ControlBar) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | ControlBar::~ControlBar() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Module/controlbar.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 controlbar.h 3 | * @功能 自定义播放控制栏 4 | * 5 | * @开发者 mhf 6 | * @邮箱 1603291350@qq.com 7 | * @时间 2022/03/26 8 | * @备注 9 | *****************************************************************************/ 10 | #ifndef CONTROLBAR_H 11 | #define CONTROLBAR_H 12 | 13 | #include 14 | 15 | namespace Ui { 16 | class ControlBar; 17 | } 18 | 19 | class ControlBar : public QWidget 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit ControlBar(QWidget *parent = nullptr); 25 | ~ControlBar(); 26 | 27 | private: 28 | Ui::ControlBar *ui; 29 | }; 30 | 31 | #endif // CONTROLBAR_H 32 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Style/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMWidget/Style/image/close.png -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Style/image/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMWidget/Style/image/max.png -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Style/image/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMWidget/Style/image/min.png -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/Style/image/restore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QMWidget/Style/image/restore.png -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/WidgetBase/WidgetBase.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/mwidgetbase.h 3 | 4 | SOURCES += \ 5 | $$PWD/mwidgetbase.cpp 6 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/WidgetBase/head.h: -------------------------------------------------------------------------------- 1 | #ifndef HEAD_H 2 | #define HEAD_H 3 | 4 | //MSVC编译器 5 | #ifdef _MSC_VER 6 | #if _MSC_VER >=1600 // VC2010 以上 7 | //#pragma execution_character_set("utf-8") 8 | #endif 9 | #endif 10 | 11 | 12 | #endif // HEAD_H 13 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Style/main.css 4 | Style/image/close.png 5 | Style/image/max.png 6 | Style/image/min.png 7 | Style/image/restore.png 8 | 9 | 10 | -------------------------------------------------------------------------------- /FunctionalModule/QMWidget/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "mwidgetbase.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public MWidgetBase 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private: 20 | void init(); // 初始化 21 | void connectSlot(); // 绑定信号槽 22 | void loadStyle(); // 加载样式表 23 | void setWindowTitle(const QString& title); 24 | 25 | 26 | private: 27 | Ui::Widget *ui; 28 | }; 29 | #endif // WIDGET_H 30 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/QRCode.pri: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------- 2 | # @功能: Qt封装的qrencode模块,用于生成二维码 3 | # @编译器: msvc2017_64(也支持其它编译器) 4 | # @Qt IDE: D:/Qt/qtcreator-10.0.2/share/qtcreator 5 | # 6 | # @开发者 mhf 7 | # @邮箱 1603291350@qq.com 8 | # @时间 2024-05-29 23:00:03 9 | # @备注 10 | #--------------------------------------------------------------------------------------- 11 | 12 | include($$PWD/src.pri) # 使用源代码(可移植性好,不受编译器限制) 13 | #include($$PWD/lib.pri) # 使用编译后的静态库(受限与编译器,默认MSVC2017-64) 14 | 15 | # 二维码显示视图 16 | HEADERS += $$PWD/qrcodeview.h 17 | SOURCES += $$PWD/qrcodeview.cpp 18 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/lib.pri: -------------------------------------------------------------------------------- 1 | 2 | CONFIG(debug, debug|release): { 3 | LIBS += -L$$PWD/QRencodeLib/lib/ -lqrencoded 4 | }else{ 5 | LIBS += -L$$PWD/QRencodeLib/lib/ -lqrencode 6 | } 7 | INCLUDEPATH += $$PWD/QRencodeLib/include 8 | DEPENDPATH += $$PWD/QRencodeLib/include 9 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/qrcodeview.h: -------------------------------------------------------------------------------- 1 | #ifndef QRCODEVIEW_H 2 | #define QRCODEVIEW_H 3 | 4 | #include 5 | #include 6 | 7 | class QrCodeView : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit QrCodeView(QWidget* parent = nullptr); 12 | 13 | void setString(const QString& str); // 传入需要编码的字符串 14 | bool save(const QString& path); // 保存生成的二维码图片到指定路径 15 | QImage getImage(); // 获取生成的二维码 16 | 17 | protected: 18 | void paintEvent(QPaintEvent* event) override; 19 | void resizeEvent(QResizeEvent* event) override; 20 | 21 | signals: 22 | 23 | private: 24 | QString m_str; 25 | QImage m_img; // 保存原图 26 | QImage m_imgShow; // 保存缩放后的图片 27 | }; 28 | 29 | #endif // QRCODEVIEW_H 30 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/lib/pkgconfig/libqrencode.pc: -------------------------------------------------------------------------------- 1 | prefix=C:/Users/MHF/Downloads/qrencode-4.1.1/QRencode 2 | exec_prefix=C:/Users/MHF/Downloads/qrencode-4.1.1/QRencode/bin 3 | libdir=C:/Users/MHF/Downloads/qrencode-4.1.1/QRencode/lib 4 | includedir=C:/Users/MHF/Downloads/qrencode-4.1.1/QRencode/include 5 | 6 | Name: libqrencode 7 | Description: A QR Code encoding library 8 | Version: 4.1.1 9 | Libs: -L${libdir} -lqrencode 10 | Libs.private: 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/lib/qrencode.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/lib/qrencode.lib -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/lib/qrencoded.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/lib/qrencoded.lib -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/qrencodeLib/编译说明.md: -------------------------------------------------------------------------------- 1 | ## 编译器 2 | 3 | - MSVC2017-64 -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/QRCode/src.pri: -------------------------------------------------------------------------------- 1 | DEFINES += HAVE_CONFIG_H 2 | INCLUDEPATH += $$PWD/qrencode 3 | HEADERS += \ 4 | $$PWD/qrencode/bitstream.h \ 5 | $$PWD/qrencode/config.h \ 6 | $$PWD/qrencode/mask.h \ 7 | $$PWD/qrencode/mmask.h \ 8 | $$PWD/qrencode/mqrspec.h \ 9 | $$PWD/qrencode/qrencode.h \ 10 | $$PWD/qrencode/qrencode_inner.h \ 11 | $$PWD/qrencode/qrinput.h \ 12 | $$PWD/qrencode/qrspec.h \ 13 | $$PWD/qrencode/rsecc.h \ 14 | $$PWD/qrencode/split.h 15 | 16 | SOURCES += \ 17 | $$PWD/qrencode/bitstream.c \ 18 | $$PWD/qrencode/mask.c \ 19 | $$PWD/qrencode/mmask.c \ 20 | $$PWD/qrencode/mqrspec.c \ 21 | $$PWD/qrencode/qrencode.c \ 22 | $$PWD/qrencode/qrinput.c \ 23 | $$PWD/qrencode/qrspec.c \ 24 | $$PWD/qrencode/rsecc.c \ 25 | $$PWD/qrencode/split.c 26 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "qrencode.h" // 添加头文件 3 | #include "ui_widget.h" 4 | #include 5 | #include 6 | #include 7 | 8 | Widget::Widget(QWidget* parent) 9 | : QWidget(parent) 10 | , ui(new Ui::Widget) 11 | { 12 | ui->setupUi(this); 13 | this->setWindowTitle("QT生成、显示二维码示例"); 14 | this->setWindowTitle(QString("QT生成、显示二维码自定义控件示例 - V%1").arg(APP_VERSION)); 15 | } 16 | 17 | Widget::~Widget() 18 | { 19 | delete ui; 20 | } 21 | 22 | void Widget::on_pushButton_clicked() 23 | { 24 | ui->qrCodeView->setString(ui->lineEdit->text()); // 生成二维码 25 | } 26 | 27 | void Widget::on_but_save_clicked() 28 | { 29 | QString path = QFileDialog::getSaveFileName(this, "二维码保存到", "./二维码.jpg", "图片 (*.jpg)"); 30 | if (path.isEmpty()) 31 | return; 32 | 33 | ui->qrCodeView->save(path); // 保存二维码 34 | } 35 | -------------------------------------------------------------------------------- /FunctionalModule/QrCodeDemo/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | 8 | namespace Ui { 9 | class Widget; 10 | } 11 | 12 | QT_END_NAMESPACE 13 | 14 | class Widget : public QWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | Widget(QWidget* parent = nullptr); 20 | ~Widget(); 21 | 22 | private slots: 23 | void on_pushButton_clicked(); 24 | 25 | void on_but_save_clicked(); 26 | 27 | private: 28 | Ui::Widget* ui; 29 | }; 30 | #endif // WIDGET_H 31 | -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/ScanFileLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(ScanFile) 3 | set(CMAKE_CXX_STANDARD 11) # 设置C++11 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 5 | 6 | include_directories(./) # 添加头文件目录 7 | # debug生成名称 8 | set(CMAKE_DEBUG_POSTFIX "d") 9 | set(SOURCES ScanFile.cpp) 10 | add_library(ScanFile SHARED ${SOURCES}) # 生成动态库 11 | 12 | # 设置导出宏 13 | target_compile_definitions(ScanFile PRIVATE SCANFILE_EXPORTS) 14 | 15 | # 安装库 16 | install(TARGETS ScanFile DESTINATION ${CMAKE_BINARY_DIR}/../lib) 17 | -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/ScanFileLib/SpinLock.h: -------------------------------------------------------------------------------- 1 | #ifndef SPINLOCK_H 2 | #define SPINLOCK_H 3 | 4 | /** 5 | * 定义一个简单的自旋锁类 SpinLock,使用 C++11 的原子操作。 6 | */ 7 | #include 8 | #include 9 | 10 | class SpinLock { 11 | public: 12 | SpinLock() 13 | { 14 | flag.clear(); 15 | } 16 | 17 | void lock() { 18 | while (flag.test_and_set(std::memory_order_acquire)); 19 | } 20 | 21 | void unlock() { 22 | flag.clear(std::memory_order_release); 23 | } 24 | 25 | private: 26 | std::atomic_flag flag; 27 | }; 28 | 29 | #endif // SPINLOCK_H -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/include/SpinLock.h: -------------------------------------------------------------------------------- 1 | #ifndef SPINLOCK_H 2 | #define SPINLOCK_H 3 | 4 | /** 5 | * 定义一个简单的自旋锁类 SpinLock,使用 C++11 的原子操作。 6 | */ 7 | #include 8 | #include 9 | 10 | class SpinLock { 11 | public: 12 | SpinLock() 13 | { 14 | flag.clear(); 15 | } 16 | 17 | void lock() { 18 | while (flag.test_and_set(std::memory_order_acquire)); 19 | } 20 | 21 | void unlock() { 22 | flag.clear(std::memory_order_release); 23 | } 24 | 25 | private: 26 | std::atomic_flag flag; 27 | }; 28 | 29 | #endif // SPINLOCK_H -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/lib/ScanFile.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/ScanFile/lib/ScanFile.dll -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/lib/ScanFile.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/ScanFile/lib/ScanFile.lib -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/lib/ScanFiled.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/ScanFile/lib/ScanFiled.dll -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/lib/ScanFiled.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/ScanFile/lib/ScanFiled.lib -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | // main函数中添加 10 | //设置中文编码 11 | #if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0)) 12 | #if _MSC_VER 13 | QTextCodec* codec = QTextCodec::codecForName("gbk"); 14 | #else 15 | QTextCodec* codec = QTextCodec::codecForName("utf-8"); 16 | #endif 17 | QTextCodec::setCodecForLocale(codec); 18 | QTextCodec::setCodecForCStrings(codec); 19 | QTextCodec::setCodecForTr(codec); 20 | #else 21 | QTextCodec* codec = QTextCodec::codecForName("utf-8"); 22 | QTextCodec::setCodecForLocale(codec); 23 | #endif 24 | 25 | Widget w; 26 | w.show(); 27 | return a.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /FunctionalModule/ScanFile/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include "ScanFile.h" 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | 10 | namespace Ui { 11 | class Widget; 12 | } 13 | 14 | QT_END_NAMESPACE 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | Widget(QWidget* parent = nullptr); 22 | ~Widget(); 23 | 24 | void fun(const FileInfo& fileInfo); 25 | private slots: 26 | void on_pushButton_clicked(bool checked); 27 | 28 | private: 29 | void on_timeout(); 30 | 31 | private: 32 | Ui::Widget* ui; 33 | ScanFile m_scanFile; 34 | quint64 m_size = 0; 35 | SpinLock m_spinLock; 36 | QString m_strFileInfo; 37 | QTimer m_timer; 38 | }; 39 | #endif // WIDGET_H 40 | -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/SnippingTool/icon.ico -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/img/cancel.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/SnippingTool/img/cancel.ico -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/img/clipping.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/SnippingTool/img/clipping.ico -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/img/precinct.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/SnippingTool/img/precinct.ico -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/img/save.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/FunctionalModule/SnippingTool/img/save.ico -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 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 | -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/playimage.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYIMAGE_H 2 | #define PLAYIMAGE_H 3 | 4 | #include 5 | #include 6 | 7 | class PlayImage : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PlayImage(QWidget *parent = nullptr); 12 | 13 | void updateImage(const QImage& image); 14 | void updatePixmap(const QPixmap& pixmap); 15 | 16 | signals: 17 | 18 | protected: 19 | void paintEvent(QPaintEvent *event) override; 20 | 21 | private: 22 | QPixmap m_pixmap; 23 | QMutex m_mutex; 24 | }; 25 | 26 | #endif // PLAYIMAGE_H 27 | -------------------------------------------------------------------------------- /FunctionalModule/SnippingTool/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/save.ico 4 | img/clipping.ico 5 | img/cancel.ico 6 | img/precinct.ico 7 | 8 | 9 | -------------------------------------------------------------------------------- /FunctionalModule/TestCrashHandler/CrashHandler/crashhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef CRASHHANDLER_H 2 | #define CRASHHANDLER_H 3 | 4 | class CrashHandler 5 | { 6 | public: 7 | CrashHandler() {} 8 | 9 | static void initCrashHandler(); // 初始化加载应用程序崩溃处理程序 10 | }; 11 | 12 | #endif // CRASHHANDLER_H 13 | -------------------------------------------------------------------------------- /FunctionalModule/TestCrashHandler/main.cpp: -------------------------------------------------------------------------------- 1 | #include "crashhandler.h" 2 | #include "widget.h" 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | CrashHandler::initCrashHandler(); // 注册崩溃处理功能 9 | Widget w; 10 | w.show(); 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /FunctionalModule/TestCrashHandler/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | #include 5 | 6 | Widget::Widget(QWidget *parent) 7 | : QWidget(parent) 8 | , ui(new Ui::Widget) 9 | { 10 | ui->setupUi(this); 11 | 12 | this->setWindowTitle(QString("Qt崩溃定位Demo - V%1").arg(APP_VERSION)); 13 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 14 | } 15 | 16 | Widget::~Widget() 17 | { 18 | delete ui; 19 | } 20 | 21 | 22 | void Widget::on_pushButton_clicked() 23 | { 24 | QWidget* w; 25 | delete w; 26 | } 27 | 28 | 29 | void Widget::on_pushButton_2_clicked() 30 | { 31 | int a= 0; 32 | int b = 100; 33 | int c = b / a; 34 | } 35 | 36 | 37 | void Widget::on_pushButton_3_clicked() 38 | { 39 | QWidget* w; 40 | w->show(); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /FunctionalModule/TestCrashHandler/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_pushButton_clicked(); 20 | 21 | void on_pushButton_2_clicked(); 22 | 23 | void on_pushButton_3_clicked(); 24 | 25 | private: 26 | Ui::Widget *ui; 27 | }; 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /FunctionalModule/WindowRect/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /FunctionalModule/WindowRect/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | class Widget : public QWidget 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | Widget(QWidget *parent = nullptr); 13 | ~Widget(); 14 | 15 | protected: 16 | void on_timeout(); 17 | private: 18 | QTimer m_timer; 19 | }; 20 | #endif // WIDGET_H 21 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsItem/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/GraphicsviewDemo/GraphicsItem/1.png -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsItem/GraphicsItem_resource.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | VS_VERSION_INFO VERSIONINFO 4 | FILEVERSION 1,0,1,0 5 | PRODUCTVERSION 1,0,1,0 6 | FILEFLAGSMASK 0x3fL 7 | #ifdef _DEBUG 8 | FILEFLAGS VS_FF_DEBUG 9 | #else 10 | FILEFLAGS 0x0L 11 | #endif 12 | FILEOS VOS__WINDOWS32 13 | FILETYPE VFT_DLL 14 | FILESUBTYPE 0x0L 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904b0" 19 | BEGIN 20 | VALUE "CompanyName", "\0" 21 | VALUE "FileDescription", "\0" 22 | VALUE "FileVersion", "1.0.1.0\0" 23 | VALUE "LegalCopyright", "\0" 24 | VALUE "OriginalFilename", "GraphicsItem.exe\0" 25 | VALUE "ProductName", "GraphicsItem\0" 26 | VALUE "ProductVersion", "1.0.1.0\0" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x0409, 1200 32 | END 33 | END 34 | /* End of Version info */ 35 | 36 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsItem/image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsItem/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 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 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsItem/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class MainWindow; } 10 | QT_END_NAMESPACE 11 | 12 | class MainWindow : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | MainWindow(QWidget *parent = nullptr); 18 | ~MainWindow(); 19 | 20 | private: 21 | void initToolBar(); 22 | void drawLine(); 23 | void drawRect(); 24 | void drawEllipse(); 25 | void drawPolygon(); 26 | void drawSimpleText(); 27 | void drawText(); 28 | void drawPixmap(); 29 | void drawPath(); 30 | void addWidget(); 31 | void drawPoints(); 32 | void clear(); 33 | 34 | private: 35 | Ui::MainWindow *ui; 36 | 37 | QButtonGroup m_butGroup; 38 | QGraphicsScene m_scene; 39 | }; 40 | #endif // MAINWINDOW_H 41 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsviewDemo.assets/GraphicsItem-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/GraphicsviewDemo/GraphicsviewDemo.assets/GraphicsItem-tuya.gif -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsviewDemo.md: -------------------------------------------------------------------------------- 1 | # GraphicsView 图形视图框架Demo 2 | 3 | [toc] 4 | 5 | --- 6 | 7 | ## 1、说明 8 | 9 | | 类名 | 功能 | 10 | | :----------: | ------------------------- | 11 | | GraphicsItem | QGraphicsItem基本图元演示 | 12 | 13 | 14 | 15 | 16 | ## 2、相关博客 17 | 18 | | 相关博客 | 19 | | :----------------------------------------------------------: | 20 | | 👉[CSDN](https://blog.csdn.net/qq_43627907/category_12033351.html)👈 | 21 | 22 | 23 | 24 | ## 3、实现效果 25 | 26 | ### 1.1 basicdrawing 27 | 28 | > 1. 包含内置的 直线、矩形、椭圆、多边形、简单文本、富文本、图片、绘图路径、窗口部件基本图元; 29 | > 2. 实现【自定义散点图元】; 30 | > 3. 实现所有图元鼠标选中、移动功能,包括窗口部件图元; 31 | > 4. 解决自定义图元鼠标移动存在残留问题。 32 | 33 | ![GraphicsItem-tuya](GraphicsviewDemo.assets/GraphicsItem-tuya.gif) 34 | -------------------------------------------------------------------------------- /GraphicsviewDemo/GraphicsviewDemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += GraphicsItem # QGraphicsItem基本图元演示 4 | -------------------------------------------------------------------------------- /MapExamples/MapDownload/downloadthreads.h: -------------------------------------------------------------------------------- 1 | #ifndef DOWNLOADTHREADS_H 2 | #define DOWNLOADTHREADS_H 3 | 4 | #include "mapStruct.h" 5 | #include 6 | #include 7 | 8 | class DownloadThreads : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit DownloadThreads(QObject* parent = nullptr); 13 | ~DownloadThreads(); 14 | 15 | // 传入需要下载的瓦片信息 16 | void getImage(QList infos); 17 | void quit(); // 退出下载 18 | 19 | signals: 20 | void finished(ImageInfo info); // 返回下载后的瓦片,由于QImage为共享内存,所以传递不需要考虑太多性能 21 | 22 | private: 23 | QFuture m_future; 24 | QList m_infos; 25 | }; 26 | 27 | #endif // DOWNLOADTHREADS_H 28 | -------------------------------------------------------------------------------- /MapExamples/MapDownload/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /MapExamples/MapDownload/mapStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPSTRUCT_H 2 | #define MAPSTRUCT_H 3 | /******************************************************************** 4 | * 文件名: mapStruct.h 5 | * 时间: 2024-01-19 22:20:45 6 | * 开发者: mhf 7 | * 邮箱: 1603291350@qq.com 8 | * 说明: 包含程序中使用到的结构体 9 | * ******************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | struct ImageInfo 16 | { 17 | // 瓦片编号 18 | int x; 19 | int y; 20 | int z; 21 | QString url; // 下载瓦片的地址 22 | QString format; // 图片格式 23 | QImage img; // 保存下载后的瓦片 24 | short count = 0; // 失败下载次数,初始为0,下载失败一次+1 25 | }; 26 | 27 | #endif // MAPSTRUCT_H 28 | -------------------------------------------------------------------------------- /MapExamples/MapDownload/mapinput.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPINPUT_H 2 | #define MAPINPUT_H 3 | 4 | #include 5 | #include "mapStruct.h" 6 | 7 | namespace Ui { 8 | class MapInput; 9 | } 10 | 11 | class MapInput : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MapInput(QWidget *parent = nullptr); 17 | ~MapInput(); 18 | 19 | const QList &getInputInfo(); // 获取下载地图所需的输入信息 20 | 21 | private: 22 | // ArcGis 23 | void initArcGis(); 24 | void getArcGisMapInfo(); 25 | // 高德 26 | void initAMap(); 27 | void getAMapInfo(); 28 | // Bing地图 29 | void initBing(); 30 | void getBingMapInfo(); 31 | 32 | private: 33 | Ui::MapInput *ui; 34 | QList m_infos; // 保存下载瓦片图片的信息 35 | }; 36 | 37 | #endif // MAPINPUT_H 38 | -------------------------------------------------------------------------------- /MapExamples/MapExamples.assets/image-20240510221601118.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/MapExamples/MapExamples.assets/image-20240510221601118.png -------------------------------------------------------------------------------- /MapExamples/MapExamples.assets/image-20240510221755393.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/MapExamples/MapExamples.assets/image-20240510221755393.png -------------------------------------------------------------------------------- /MapExamples/MapExamples.assets/image-20240510222139643.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/MapExamples/MapExamples.assets/image-20240510222139643.png -------------------------------------------------------------------------------- /MapExamples/MapExamples.assets/image-20240602194658596.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/MapExamples/MapExamples.assets/image-20240602194658596.png -------------------------------------------------------------------------------- /MapExamples/MapExamples.pro: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------- 2 | # @功能: 与地图相关的示例代码 3 | # @编译器: Desktop Qt 5.14.2 MSVC2017 64bit(也支持其它编译器) 4 | # @Qt IDE: D:/Qt/Qt5.14.2/Tools/QtCreator/share/qtcreator 5 | # 6 | # @开发者 mhf 7 | # @邮箱 1603291350@qq.com 8 | # @时间 2024-03-29 14:45:06 9 | # @备注 10 | #--------------------------------------------------------------------------------------- 11 | 12 | TEMPLATE = subdirs 13 | 14 | SUBDIRS += MapDownload # 简单的瓦片地图下载示例 15 | SUBDIRS += MapView # Qt使用QGraphicsView显示瓦片地图简单示例 16 | SUBDIRS += MapView2 # Qt以绝对像素坐标显示离线瓦片地图 17 | SUBDIRS += MapView3 # Qt以绝对像素坐标显示在线瓦片地图 18 | -------------------------------------------------------------------------------- /MapExamples/MapView/MapView/MapView.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/mapgraphicsview.h 3 | 4 | SOURCES += \ 5 | $$PWD/mapgraphicsview.cpp 6 | -------------------------------------------------------------------------------- /MapExamples/MapView/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /MapExamples/MapView/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_pushButton_clicked(); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /MapExamples/MapView2/MapView/MapView.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/bingformula.h \ 3 | $$PWD/mapStruct.h \ 4 | $$PWD/mapgraphicsview.h 5 | 6 | SOURCES += \ 7 | $$PWD/bingformula.cpp \ 8 | $$PWD/mapgraphicsview.cpp 9 | -------------------------------------------------------------------------------- /MapExamples/MapView2/MapView/mapStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPSTRUCT_H 2 | #define MAPSTRUCT_H 3 | /******************************************************************** 4 | * 文件名: mapStruct.h 5 | * 时间: 2024-01-19 22:20:45 6 | * 开发者: mhf 7 | * 邮箱: 1603291350@qq.com 8 | * 说明: 包含程序中使用到的结构体 9 | * ******************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | struct ImageInfo 16 | { 17 | // 瓦片编号 18 | int x; 19 | int y; 20 | int z; 21 | QString url; // 下载瓦片的地址 22 | QString format; // 图片格式 23 | QPixmap img; // 保存下载后的瓦片 24 | short count = 0; // 失败下载次数,初始为0,下载失败一次+1 25 | }; 26 | 27 | #endif // MAPSTRUCT_H 28 | -------------------------------------------------------------------------------- /MapExamples/MapView2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /MapExamples/MapView3/MapView/MapView.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/bingformula.h \ 3 | $$PWD/geturl.h \ 4 | $$PWD/graphicsitemgroup.h \ 5 | $$PWD/mapStruct.h \ 6 | $$PWD/mapgraphicsview.h 7 | 8 | SOURCES += \ 9 | $$PWD/bingformula.cpp \ 10 | $$PWD/geturl.cpp \ 11 | $$PWD/graphicsitemgroup.cpp \ 12 | $$PWD/mapgraphicsview.cpp 13 | -------------------------------------------------------------------------------- /MapExamples/MapView3/MapView/graphicsitemgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSITEMGROUP_H 2 | #define GRAPHICSITEMGROUP_H 3 | 4 | #include "mapStruct.h" 5 | #include 6 | 7 | class GraphicsItemGroup : public QGraphicsItemGroup 8 | { 9 | public: 10 | explicit GraphicsItemGroup(QGraphicsItem* parent = nullptr); 11 | ~GraphicsItemGroup() override; 12 | 13 | void addImage(const ImageInfo& info); // 添加瓦片图 14 | 15 | private: 16 | QHash m_itemsImg; // 保存瓦片地图图元 17 | QHash m_itemsR; // 保存瓦片地图图元 18 | QHash m_itemsText; // 保存瓦片地图图元 19 | }; 20 | 21 | #endif // GRAPHICSITEMGROUP_H 22 | -------------------------------------------------------------------------------- /MapExamples/MapView3/MapView/mapStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef MAPSTRUCT_H 2 | #define MAPSTRUCT_H 3 | /******************************************************************** 4 | * 文件名: mapStruct.h 5 | * 时间: 2024-01-19 22:20:45 6 | * 开发者: mhf 7 | * 邮箱: 1603291350@qq.com 8 | * 说明: 包含程序中使用到的结构体 9 | * ******************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | struct ImageInfo 16 | { 17 | // 瓦片编号 18 | int x = 0; 19 | int y = 0; 20 | int z = 0; 21 | QString url; // 下载瓦片的地址 22 | QString format; // 图片格式 23 | QPixmap img; // 保存下载后的瓦片 24 | short count = 0; // 失败下载次数,初始为0,下载失败一次+1 25 | }; 26 | 27 | #endif // MAPSTRUCT_H 28 | -------------------------------------------------------------------------------- /MapExamples/MapView3/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /MapExamples/MapView3/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include "geturl.h" 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | 9 | namespace Ui { 10 | class Widget; 11 | } 12 | 13 | QT_END_NAMESPACE 14 | 15 | class Widget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | Widget(QWidget* parent = nullptr); 21 | ~Widget(); 22 | 23 | private slots: 24 | void on_com_url_activated(int index); 25 | 26 | void on_com_url_editTextChanged(const QString& arg1); 27 | 28 | void on_but_clear_clicked(); 29 | 30 | private: 31 | void showRect(QRect rect); 32 | 33 | private: 34 | Ui::Widget* ui; 35 | GetUrl* m_geturl = nullptr; 36 | }; 37 | #endif // WIDGET_H 38 | -------------------------------------------------------------------------------- /OpenCVDemo/OpenCVDemo.assets/VideoPlay1-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/OpenCVDemo/OpenCVDemo.assets/VideoPlay1-tuya.gif -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/playimage.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYIMAGE_H 2 | #define PLAYIMAGE_H 3 | 4 | #include 5 | 6 | class PlayImage : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit PlayImage(QWidget *parent = nullptr); 11 | 12 | void updateImage(const QImage& image); 13 | void updatePixmap(const QPixmap& pixmap); 14 | 15 | signals: 16 | 17 | protected: 18 | void paintEvent(QPaintEvent *event) override; 19 | 20 | private: 21 | QPixmap m_pixmap; 22 | 23 | }; 24 | 25 | #endif // PLAYIMAGE_H 26 | -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/videodisplay.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEODISPLAY_H 2 | #define VIDEODISPLAY_H 3 | 4 | #include 5 | #include 6 | 7 | using namespace cv; 8 | 9 | namespace Ui { 10 | class VideoDisplay; 11 | } 12 | 13 | class VideoDisplay : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit VideoDisplay(QWidget *parent = nullptr); 19 | ~VideoDisplay(); 20 | 21 | signals: 22 | void updateImage(QImage img); 23 | 24 | private slots: 25 | void on_but_open_clicked(); 26 | void readImage(); 27 | void quitThread(); 28 | QImage MatToQImage(const Mat& mat); 29 | 30 | void on_but_play_clicked(); 31 | 32 | void on_but_file_clicked(); 33 | 34 | private: 35 | Ui::VideoDisplay *ui; 36 | 37 | VideoCapture* m_cap = nullptr; 38 | Mat mat; 39 | bool m_play = false; 40 | }; 41 | 42 | #endif // VIDEODISPLAY_H 43 | -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/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 | this->resize(800, 700); 10 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 11 | this->setWindowTitle(QString("Qt使用opencv打开摄像头、本地视频、网络视频流演示Demo - V%1").arg(APP_VERSION)); 12 | } 13 | 14 | Widget::~Widget() 15 | { 16 | delete ui; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | Ui::Widget *ui; 20 | }; 21 | #endif // WIDGET_H 22 | -------------------------------------------------------------------------------- /OpenCVDemo/VideoPlay/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 693 10 | 608 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | VideoDisplay 25 | QWidget 26 |
videodisplay.h
27 | 1 28 |
29 |
30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /OpenGLDemo/OpenGLDemo.assets/TestOpenGLWindow1-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/OpenGLDemo/OpenGLDemo.assets/TestOpenGLWindow1-tuya.gif -------------------------------------------------------------------------------- /OpenGLDemo/OpenGLDemo.assets/TestOpenGLWindow2-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/OpenGLDemo/OpenGLDemo.assets/TestOpenGLWindow2-tuya.gif -------------------------------------------------------------------------------- /OpenGLDemo/OpenGLDemo.pro: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------- 2 | # @功能: Qt OpenGL开发Demo 3 | # @编译器: Desktop Qt 5.12.5 MSVC2017 64bit(也支持其它编译器) 4 | # @Qt IDE: D:/Qt/Qt5.12.5/Tools/QtCreator/share/qtcreator 5 | # 6 | # @开发者 mhf 7 | # @邮箱 1603291350@qq.com 8 | # @时间 2022-09-28 17:19:48 9 | # @备注 10 | #--------------------------------------------------------------------------------------- 11 | TEMPLATE = subdirs 12 | 13 | SUBDIRS += TestOpenGLWindow # Qt+OpenGL绘制三角形-QOpenGLWidget和QOpenGLWindow性能比较 14 | -------------------------------------------------------------------------------- /OpenGLDemo/TestOpenGLWindow/Shader.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fragmentShader.fsh 4 | vertexShader.vsh 5 | 6 | 7 | -------------------------------------------------------------------------------- /OpenGLDemo/TestOpenGLWindow/fragmentShader.fsh: -------------------------------------------------------------------------------- 1 | varying highp vec4 qt_TexCoord0; 2 | 3 | void main(void) 4 | { 5 | gl_FragColor = qt_TexCoord0; // 片元颜色值 6 | } 7 | -------------------------------------------------------------------------------- /OpenGLDemo/TestOpenGLWindow/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /OpenGLDemo/TestOpenGLWindow/vertexShader.vsh: -------------------------------------------------------------------------------- 1 | attribute highp vec4 qt_Vertex; // 顶点坐标数组 2 | attribute highp vec4 qt_MultiTexCoord0; // 顶点颜色数组 3 | uniform highp mat4 qt_ModelViewProjectionMatrix; // 模型视图投影矩阵(用于缩放、旋转等设置) 4 | varying highp vec4 qt_TexCoord0; 5 | 6 | void main(void) 7 | { 8 | gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; // 顶点位置坐标 9 | qt_TexCoord0 = qt_MultiTexCoord0; 10 | } 11 | -------------------------------------------------------------------------------- /PaintingDemo/Concentriccircles/circlewidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCLEWIDGET_H 2 | #define CIRCLEWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | class CircleWidget : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit CircleWidget(QWidget *parent = nullptr); 12 | 13 | void setFloatBased(bool flag); // 设置是否使用浮点型数据类型来保存绘制图案的数据 14 | void setAntialiased(bool flag); // 是否使用抗锯齿渲染 15 | void setFrame(int value); 16 | 17 | signals: 18 | 19 | public slots: 20 | 21 | protected: 22 | void paintEvent(QPaintEvent *event) override; 23 | 24 | private: 25 | bool floatBased = false; // 是否使用浮点类型数绘制 26 | bool antialiased = false; // 是否开启抗锯齿 27 | int frameNo = 0; 28 | }; 29 | 30 | #endif // CIRCLEWIDGET_H 31 | -------------------------------------------------------------------------------- /PaintingDemo/Concentriccircles/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/Concentriccircles/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_horizontalSlider_valueChanged(int value); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /PaintingDemo/Imagecomposition/Image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/butterfly.png 4 | images/checker.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /PaintingDemo/Imagecomposition/images/butterfly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/Imagecomposition/images/butterfly.png -------------------------------------------------------------------------------- /PaintingDemo/Imagecomposition/images/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/Imagecomposition/images/checker.png -------------------------------------------------------------------------------- /PaintingDemo/Imagecomposition/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/PainterPaths/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/PainterPaths/renderarea.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERAREA_H 2 | #define RENDERAREA_H 3 | 4 | #include 5 | 6 | class RenderArea : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit RenderArea(QWidget *parent = nullptr); 11 | 12 | void setFill(bool flag); 13 | 14 | public slots: 15 | 16 | private: 17 | void initPath(); 18 | 19 | protected: 20 | void paintEvent(QPaintEvent *event) override; 21 | 22 | private: 23 | QList m_paths; 24 | QPainterPath m_path; 25 | bool m_isFill = false; // 是否使用填充 26 | }; 27 | 28 | #endif // RENDERAREA_H 29 | -------------------------------------------------------------------------------- /PaintingDemo/PainterPaths/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 | this->resize(800, 700); 11 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 12 | this->setWindowTitle(QString("QPainterPath使用示例 - V%1").arg(APP_VERSION)); 13 | ui->widget_2->setFill(true); 14 | } 15 | 16 | Widget::~Widget() 17 | { 18 | delete ui; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /PaintingDemo/PainterPaths/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | Ui::Widget *ui; 20 | }; 21 | #endif // WIDGET_H 22 | -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/Concentriccircles-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/Concentriccircles-tuya.gif -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/TransformDemo-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/TransformDemo-tuya.gif -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/Transformations.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/Transformations.gif -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/basicdrawing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/basicdrawing.gif -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/image-20220801122927716.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/image-20220801122927716.png -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.assets/playImage.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PaintingDemo.assets/playImage.gif -------------------------------------------------------------------------------- /PaintingDemo/PaintingDemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += basicdrawing # QPainter基本绘图Demo 4 | SUBDIRS += Imagecomposition # QPainter图像合成Demo 5 | SUBDIRS += Concentriccircles # QPainter绘制时【数据类型】和【抗锯齿】对效果的影响 6 | SUBDIRS += PainterPaths # QPainterPath使用示例 7 | SUBDIRS += Transformations # QPainter偏移原点、旋转、缩放功能Demo 8 | SUBDIRS += TransformDemo # QTransform偏移原点、旋转、缩放功能Demo 9 | SUBDIRS += PlayImage # 使用 QPainter绘制图片 10 | -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PlayImage/0.jpg -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PlayImage/1.jpg -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/PlayImage/2.jpg -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.jpg 4 | 2.jpg 5 | 0.jpg 6 | 7 | 8 | -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/playimage.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYIMAGE_H 2 | #define PLAYIMAGE_H 3 | 4 | #include 5 | #include 6 | 7 | class PlayImage : public QWidget 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit PlayImage(QWidget *parent = nullptr); 12 | 13 | void updateImage(const QImage& image); 14 | void updatePixmap(const QPixmap& pixmap); 15 | 16 | signals: 17 | 18 | protected: 19 | void paintEvent(QPaintEvent *event) override; 20 | 21 | private: 22 | QPixmap m_pixmap; 23 | QMutex m_mutex; 24 | }; 25 | 26 | #endif // PLAYIMAGE_H 27 | -------------------------------------------------------------------------------- /PaintingDemo/PlayImage/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include "playimage.h" 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private: 20 | void on_timerout(); 21 | 22 | private: 23 | Ui::Widget *ui; 24 | 25 | QTimer m_timer; 26 | QPixmap m_pixmap[2]; 27 | QList m_playImages; 28 | }; 29 | #endif // WIDGET_H 30 | -------------------------------------------------------------------------------- /PaintingDemo/TransformDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/TransformDemo/renderarea.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERAREA_H 2 | #define RENDERAREA_H 3 | 4 | #include 5 | 6 | class RenderArea : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit RenderArea(QWidget *parent = nullptr); 11 | ~RenderArea() override; 12 | 13 | void setTransform(const QTransform &transform); 14 | 15 | private: 16 | void showData(); 17 | 18 | protected: 19 | void paintEvent(QPaintEvent *event) override; 20 | 21 | public slots: 22 | 23 | private: 24 | QTransform m_transform; 25 | }; 26 | 27 | #endif // RENDERAREA_H 28 | -------------------------------------------------------------------------------- /PaintingDemo/Transformations/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /PaintingDemo/Transformations/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PaintingDemo/basicdrawing/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/PaintingDemo/basicdrawing/1.png -------------------------------------------------------------------------------- /PaintingDemo/basicdrawing/image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /PaintingDemo/basicdrawing/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/abstractsensor.cpp: -------------------------------------------------------------------------------- 1 | #include "abstractsensor.h" 2 | #include 3 | 4 | AbstractSensor::AbstractSensor(QObject *parent) : QObject(parent) 5 | { 6 | qDebug() << "创建一个AbstractSensor"; 7 | } 8 | 9 | AbstractSensor::~AbstractSensor() 10 | { 11 | delete m_handleThread; 12 | m_handleThread = nullptr; 13 | 14 | qDebug() << "~AbstractSensor()"; 15 | } 16 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/abstractthread.cpp: -------------------------------------------------------------------------------- 1 | #include "abstractthread.h" 2 | #include 3 | #include 4 | 5 | AbstractThread::AbstractThread(QObject *parent) : QObject(parent) 6 | { 7 | m_thread = new QThread(); 8 | this->moveToThread(m_thread); 9 | m_thread->start(); 10 | 11 | connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater); // 退出后释放QThread对象资源 12 | connect(this, &AbstractThread::inputData, this, &AbstractThread::handleData); 13 | 14 | 15 | qDebug() << "创建一个AbstractThread"; 16 | } 17 | 18 | AbstractThread::~AbstractThread() 19 | { 20 | #if 1 21 | m_thread->quit(); // 通知线程退出 22 | m_thread->wait(); // 等待线程退出 23 | #else 24 | m_thread->exit(); // 这里方式如果线程没有立刻退出则会报错 25 | delete m_thread; // 直接关闭线程 26 | #endif 27 | m_thread = nullptr; 28 | 29 | qDebug() << "~AbstractThread()"; 30 | } 31 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/handletcpthread.cpp: -------------------------------------------------------------------------------- 1 | #include "handletcpthread.h" 2 | 3 | #include 4 | #include 5 | 6 | handleTcpThread::handleTcpThread(QObject *parent) : AbstractThread(parent) 7 | { 8 | qDebug() << "创建一个handleTcpThread"; 9 | } 10 | 11 | handleTcpThread::~handleTcpThread() 12 | { 13 | QThread::sleep(1); // 阻塞1秒,模拟线程没有离开终止 14 | qDebug() << "~handleTcpThread()"; 15 | } 16 | 17 | /** 18 | * @brief 处理传入的数据 19 | * @param arr 20 | */ 21 | void handleTcpThread::handleData(QByteArray arr) 22 | { 23 | qDebug() << QString("这里是传入的数据长度:%1").arg(arr.count()); 24 | 25 | emit outputData(arr); // 将处理后的数据传递处理 26 | } 27 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/handletcpthread.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 handletcpthread.h 3 | * @功能 解析tcp数据的线程 4 | * 5 | * @开发者 mhf 6 | * @邮箱 1603291350@qq.com 7 | * @时间 2022/05/10 8 | * @备注 9 | *****************************************************************************/ 10 | #ifndef HANDLETCPTHREAD_H 11 | #define HANDLETCPTHREAD_H 12 | 13 | #include "abstractthread.h" 14 | 15 | class handleTcpThread : public AbstractThread 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit handleTcpThread(QObject *parent = nullptr); 20 | ~handleTcpThread(); 21 | 22 | 23 | protected: 24 | void handleData(QByteArray arr) override; // 处理传入的数据,通过子类重写用于处理不同的数据 25 | 26 | signals: 27 | 28 | }; 29 | 30 | #endif // HANDLETCPTHREAD_H 31 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /ProgramFramework/DeviceControlDemo/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "abstractsensor.h" 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_outputData(QByteArray arr); 21 | void on_openState(bool flag); 22 | void on_but_init_clicked(); 23 | 24 | void on_but_open_clicked(); 25 | 26 | void on_but_close_clicked(); 27 | 28 | void on_but_write_clicked(); 29 | 30 | void on_but_delete_clicked(); 31 | 32 | private: 33 | Ui::Widget *ui; 34 | AbstractSensor* m_sensor = nullptr; 35 | }; 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /ProgramFramework/ProgramFramework.assets/DeviceControlDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/ProgramFramework/ProgramFramework.assets/DeviceControlDemo.gif -------------------------------------------------------------------------------- /ProgramFramework/ProgramFramework.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += DeviceControlDemo # Qt多通信接口适配器程序Demo 4 | -------------------------------------------------------------------------------- /QMNetwork/NetInterface/NetInterface.pri: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------- 2 | # 功能: 获取设备网络信息 3 | # 编译器: 4 | # 5 | # @开发者 mhf 6 | # @邮箱 1603291350@qq.com 7 | # @时间 2022/04/21 8 | # @备注 9 | #--------------------------------------------------------- 10 | 11 | FORMS += \ 12 | $$PWD/netproperty.ui 13 | 14 | HEADERS += \ 15 | $$PWD/netproperty.h 16 | 17 | SOURCES += \ 18 | $$PWD/netproperty.cpp 19 | -------------------------------------------------------------------------------- /QMNetwork/NetWidget/NetWidget.pri: -------------------------------------------------------------------------------- 1 | FORMS += \ 2 | $$PWD/tcpclient.ui \ 3 | $$PWD/tcpserver.ui \ 4 | $$PWD/udpsocket.ui 5 | 6 | HEADERS += \ 7 | $$PWD/tcpclient.h \ 8 | $$PWD/tcpserver.h \ 9 | $$PWD/udpsocket.h 10 | 11 | SOURCES += \ 12 | $$PWD/tcpclient.cpp \ 13 | $$PWD/tcpserver.cpp \ 14 | $$PWD/udpsocket.cpp 15 | -------------------------------------------------------------------------------- /QMNetwork/QMNetwork.assets/NetProperty.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QMNetwork/QMNetwork.assets/NetProperty.gif -------------------------------------------------------------------------------- /QMNetwork/QMNetwork.assets/TcpClient.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QMNetwork/QMNetwork.assets/TcpClient.gif -------------------------------------------------------------------------------- /QMNetwork/QMNetwork.assets/TcpServer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QMNetwork/QMNetwork.assets/TcpServer.gif -------------------------------------------------------------------------------- /QMNetwork/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | Widget w; 12 | w.show(); 13 | return a.exec(); 14 | } 15 | -------------------------------------------------------------------------------- /QSqlDemo/CachedTable/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | class QSqlTableModel; 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | 20 | private slots: 21 | void on_but_submit_clicked(); 22 | 23 | void on_but_revert_clicked(); 24 | 25 | void on_but_quit_clicked(); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | QSqlTableModel* m_model = nullptr; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/CachedTable.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/CachedTable.gif -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/RelationalTableModel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/RelationalTableModel.gif -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/SignIn-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/SignIn-tuya.gif -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/SqlWidgetMapper.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/SqlWidgetMapper.gif -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/TableModel2-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/TableModel2-tuya.gif -------------------------------------------------------------------------------- /QSqlDemo/QSql.assets/image-20220518112255014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QSqlDemo/QSql.assets/image-20220518112255014.png -------------------------------------------------------------------------------- /QSqlDemo/QSqlDemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += TableModel # (1) 这个Demo中展示了如何使用具有表视图的专用 SQL 表模型(QSqlTableModel)来编辑数据库中的信息。 4 | SUBDIRS += TableModel2 # (2) 这个Demo中展示了如何使用具有表视图的专用 SQL 表模型(QSqlTableModel)来编辑数据库中的信息,实现创建空白数据行、自增key 5 | SUBDIRS += CachedTable # (3) 通过QSqlTableModel显示和修改数据,通过按键保存修改内容和恢复修改内容 6 | SUBDIRS += RelationalTableModel # (4) 本示例展示了如何使用QSqlRelationalTableModel(关系表模型)来可视化数据库中[外键]的使用。 7 | SUBDIRS += SqlWidgetMapper # (5) 通过QDataWidgetMapper将数据库数据映射到小部件 8 | SUBDIRS += SignIn # (6) 使用QSqlite数据库实现用户登录、后台管理用户功能 9 | -------------------------------------------------------------------------------- /QSqlDemo/SignIn/dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOG_H 2 | #define DIALOG_H 3 | 4 | #include 5 | #include 6 | #include "userbackstage.h" 7 | 8 | namespace Ui { 9 | class Dialog; 10 | } 11 | 12 | class Dialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit Dialog(QWidget *parent = nullptr); 18 | ~Dialog(); 19 | 20 | static bool loggedIn(); 21 | static QString userName(); 22 | static UserBackstage::UserType type(); 23 | 24 | private slots: 25 | bool isTableExists(const QString& table); 26 | void on_but_signIn_clicked(); 27 | 28 | private: 29 | Ui::Dialog *ui; 30 | QSqlDatabase m_db; 31 | static bool m_loggedIn; // 登录状态 32 | static QString m_userName; // 登录的用户名 33 | static UserBackstage::UserType m_userType; // 用户类型 34 | }; 35 | 36 | #endif // DIALOG_H 37 | -------------------------------------------------------------------------------- /QSqlDemo/SignIn/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "dialog.h" 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | qApp->setStyleSheet("*{font: 9pt '宋体';}"); 9 | // 打开登录界面 10 | Dialog signIn; 11 | signIn.exec(); 12 | 13 | if(!signIn.loggedIn()) // 登录失败直接退出 14 | { 15 | return 0; 16 | } 17 | // 登录成功打开主界面 18 | Widget w; 19 | w.show(); 20 | return a.exec(); 21 | } 22 | -------------------------------------------------------------------------------- /QSqlDemo/SignIn/userbackstage.h: -------------------------------------------------------------------------------- 1 | #ifndef USERBACKSTAGE_H 2 | #define USERBACKSTAGE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class UserBackstage; 9 | } 10 | 11 | class UserBackstage : public QDialog 12 | { 13 | Q_OBJECT 14 | public: 15 | enum UserType { 16 | User, // 普通用户 17 | Admin, // 普通管理员 18 | Root // 超级管理员(唯一) 19 | }; 20 | public: 21 | explicit UserBackstage(QWidget *parent = nullptr); 22 | ~UserBackstage(); 23 | 24 | void setUserType(UserType type); 25 | 26 | private slots: 27 | void on_but_set_clicked(); 28 | 29 | void on_but_delete_clicked(); 30 | 31 | private: 32 | Ui::UserBackstage *ui; 33 | QSqlTableModel* m_model = nullptr; // 创建一个 单个数据库表的可编辑数据模型 34 | UserType m_userType; 35 | }; 36 | 37 | #endif // USERBACKSTAGE_H 38 | -------------------------------------------------------------------------------- /QSqlDemo/SignIn/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void initModel(); 22 | bool isTableExists(const QString& table); 23 | void on_but_connect_clicked(); 24 | 25 | void on_but_add_clicked(); 26 | 27 | void on_but_read_clicked(); 28 | 29 | void on_but_user_clicked(); 30 | 31 | private: 32 | Ui::Widget *ui; 33 | QSqlTableModel* m_model = nullptr; // 创建一个 单个数据库表的可编辑数据模型 34 | QSqlDatabase m_db; 35 | }; 36 | #endif // WIDGET_H 37 | -------------------------------------------------------------------------------- /QSqlDemo/SqlWidgetMapper/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QSqlDemo/SqlWidgetMapper/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | class QSqlRelationalTableModel; 9 | class QItemSelectionModel; 10 | class QDataWidgetMapper; 11 | QT_END_NAMESPACE 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | Widget(QWidget *parent = nullptr); 19 | ~Widget(); 20 | 21 | private: 22 | void setupModel(); 23 | 24 | private slots: 25 | void updateButtons(int row); 26 | 27 | private: 28 | Ui::Widget *ui; 29 | QSqlRelationalTableModel* m_model = nullptr; 30 | QItemSelectionModel* m_selectionModel = nullptr; 31 | QDataWidgetMapper* m_mapper = nullptr; 32 | int m_index = 0; 33 | }; 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /QSqlDemo/TableModel2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QSqlDemo/TableModel2/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void initModel(); 22 | bool isTableExists(const QString& table); 23 | void on_but_connect_clicked(); 24 | 25 | void on_but_add_clicked(); 26 | 27 | void on_but_read_clicked(); 28 | 29 | private: 30 | Ui::Widget *ui; 31 | QSqlTableModel* m_model = nullptr; // 创建一个 单个数据库表的可编辑数据模型 32 | QSqlDatabase m_db; 33 | }; 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /QStyleDemo/IconDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QStyleDemo/IconDemo/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private slots: 19 | void on_com_iconEnum_activated(int index); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QStyleDemo/QStyleDemo.assets/QssDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QStyleDemo.assets/QssDemo.gif -------------------------------------------------------------------------------- /QStyleDemo/QStyleDemo.assets/QssProperty-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QStyleDemo.assets/QssProperty-tuya.gif -------------------------------------------------------------------------------- /QStyleDemo/QStyleDemo.assets/icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QStyleDemo.assets/icon.gif -------------------------------------------------------------------------------- /QStyleDemo/QStyleDemo.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += QssDemo # Qss样式表练习Demo(包含常用控件) 4 | SUBDIRS += QssProperty # QSS样式表使用---属性功能 5 | SUBDIRS += IconDemo # Qt使用QStyle内置图标Demo 6 | -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/CheckBox_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/CheckBox_unchecked.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/Checkbox_Select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/Checkbox_Select.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/Checkbox_notAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/Checkbox_notAll.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/RadioBox_Unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/RadioBox_Unchecked.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/RadioBox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/RadioBox_checked.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/bg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/bg.PNG -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/close.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/down.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/down_d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/down_d.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/laft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/laft.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/plus.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/reduce.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/reduce.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/right.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/undock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/undock.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/image/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QStyleDemo/QssDemo/image/up.png -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | 10 | 11 | QTextCodec *codec = QTextCodec::codecForName("utf-8"); 12 | QTextCodec::setCodecForLocale(codec); // 设置使用utf-8字符编码,否则qss有中文则无法生效 13 | 14 | MainWindow w; 15 | w.show(); 16 | return a.exec(); 17 | } 18 | -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class MainWindow; } 9 | QT_END_NAMESPACE 10 | 11 | class MainWindow : public QMainWindow 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | MainWindow(QWidget *parent = nullptr); 17 | ~MainWindow(); 18 | 19 | private slots: 20 | void on_checkBox_stateChanged(int arg1); 21 | 22 | void on_tabWidget_2_tabCloseRequested(int index); 23 | 24 | private: 25 | void init(); 26 | void initListView(); 27 | void initTreeView(); 28 | void initTableView(); 29 | void initStyle(); 30 | void connectSlots(); 31 | 32 | private: 33 | Ui::MainWindow *ui; 34 | QStringListModel* strModel = nullptr; 35 | }; 36 | #endif // MAINWINDOW_H 37 | -------------------------------------------------------------------------------- /QStyleDemo/QssDemo/style.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | style.css 4 | image/bg.PNG 5 | image/Checkbox_notAll.png 6 | image/Checkbox_Select.png 7 | image/CheckBox_unchecked.png 8 | image/RadioBox_Unchecked.png 9 | image/RadioBox_checked.png 10 | image/down.png 11 | image/close.png 12 | image/undock.png 13 | image/laft.png 14 | image/right.png 15 | image/up.png 16 | image/down_d.png 17 | image/plus.png 18 | image/reduce.png 19 | 20 | 21 | -------------------------------------------------------------------------------- /QStyleDemo/QssProperty/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QStyleDemo/QssProperty/style.css: -------------------------------------------------------------------------------- 1 | /* 设置Q_PROPERTY定义的属性样式 */ 2 | #Widget[checked = true] { 3 | background-color: rgb(0, 255, 127); 4 | } 5 | 6 | /* 设置动态属性样式 */ 7 | #Widget[property1 = true] { 8 | background-color: rgb(255, 0, 127); 9 | } 10 | 11 | /* 通过Qss设置Q_PROPERTY定义的属性的值 */ 12 | #Widget { 13 | qproperty-BgColor: rgb(255, 0, 0); 14 | qproperty-age: age3; /* 通过Q_ENUM注册的枚举修改自定义属性值*/ 15 | } 16 | -------------------------------------------------------------------------------- /QtChartsDemo/AreaChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/AreaChart/widget.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @文件名 widget.h 3 | * @功能 该示例显示了如何创建简单的面积图,在源码中包含使用的说明注释和注意事项 4 | * 去除了Qt示例中的警告信息、一些过时的用法和危险的用法, 5 | * 6 | * @开发者 mhf 7 | * @邮箱 1603291350@qq.com 8 | * @时间 2022/04/24 9 | * @备注 10 | *****************************************************************************/ 11 | #ifndef WIDGET_H 12 | #define WIDGET_H 13 | 14 | #include 15 | 16 | QT_BEGIN_NAMESPACE 17 | namespace Ui { class Widget; } 18 | QT_END_NAMESPACE 19 | 20 | class Widget : public QWidget 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | Widget(QWidget *parent = nullptr); 26 | ~Widget(); 27 | 28 | private: 29 | void initChart(); // 初始化绘制图表 30 | 31 | private: 32 | Ui::Widget *ui; 33 | }; 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /QtChartsDemo/AreaChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 724 10 | 560 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/Audio/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/Audio/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/BarChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/BarChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); // 初始化绘制图表 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QtChartsDemo/BarChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/BoxPlotChart/data.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | acme.txt 4 | 5 | 6 | -------------------------------------------------------------------------------- /QtChartsDemo/BoxPlotChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/BoxPlotChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | QT_CHARTS_USE_NAMESPACE // 引入命名空间,必须放在ui_widget.h前 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class Widget; } 10 | QT_END_NAMESPACE 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private: 21 | void initChart(); // 初始化绘制图表 22 | QList getData(); // 获取用于绘制的盒须图数据 23 | qreal findMedian(QList& sortedList, int begin, int end); 24 | 25 | private: 26 | Ui::Widget *ui; 27 | }; 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /QtChartsDemo/BoxPlotChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/CandlestickChart/data.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | acme.txt 4 | 5 | 6 | -------------------------------------------------------------------------------- /QtChartsDemo/CandlestickChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/CandlestickChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | QT_CHARTS_USE_NAMESPACE // 为了便于 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | Widget(QWidget *parent = nullptr); 19 | ~Widget(); 20 | 21 | private: 22 | void initChart(); // 初始化绘制图表 23 | QList getData(); // 获取需要绘制数据 24 | 25 | private: 26 | Ui::Widget *ui; 27 | }; 28 | #endif // WIDGET_H 29 | -------------------------------------------------------------------------------- /QtChartsDemo/CandlestickChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/DonutChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/DonutChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QtChartsDemo/DonutChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/LineChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/LineChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QtChartsDemo/LineChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/PictureScroll/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/PictureScroll/1.jpg -------------------------------------------------------------------------------- /QtChartsDemo/PictureScroll/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/PictureScroll/1.png -------------------------------------------------------------------------------- /QtChartsDemo/PictureScroll/img.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.jpg 4 | 1.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /QtChartsDemo/PictureScroll/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/PictureScroll/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_pushButton_clicked(); 21 | void on_timeout(); 22 | 23 | private: 24 | Ui::Widget *ui; 25 | QTimer m_timer; 26 | }; 27 | #endif // WIDGET_H 28 | -------------------------------------------------------------------------------- /QtChartsDemo/PieChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/PieChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); // 初始化绘制饼图 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QtChartsDemo/PieChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/PolarChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/PolarChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); // 初始化绘制图表 20 | 21 | private: 22 | Ui::Widget *ui; 23 | }; 24 | #endif // WIDGET_H 25 | -------------------------------------------------------------------------------- /QtChartsDemo/PolarChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/BarChart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/BarChart.gif -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/BoxPlotChart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/BoxPlotChart.gif -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/CandlestickChart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/CandlestickChart.gif -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/PictureScroll-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/PictureScroll-tuya.gif -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/ScatterChart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/ScatterChart.gif -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220425003919970.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220425003919970.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220425003959893.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220425003959893.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220428211944287.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220428211944287.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220501141335238.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220501141335238.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220501141454183.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220501141454183.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220503224142003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220503224142003.png -------------------------------------------------------------------------------- /QtChartsDemo/QtCharts.assets/image-20220507213204801.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/QtChartsDemo/QtCharts.assets/image-20220507213204801.png -------------------------------------------------------------------------------- /QtChartsDemo/ScatterChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/ScatterChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); // 初始化绘制图表 20 | 21 | private slots: 22 | void on_pushButton_clicked(); 23 | 24 | void on_pushButton_2_clicked(); 25 | 26 | void on_pushButton_3_clicked(); 27 | 28 | private: 29 | Ui::Widget *ui; 30 | }; 31 | #endif // WIDGET_H 32 | -------------------------------------------------------------------------------- /QtChartsDemo/SplineChart/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtChartsDemo/SplineChart/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | void initChart(); // 初始化绘制图表 20 | private: 21 | Ui::Widget *ui; 22 | }; 23 | #endif // WIDGET_H 24 | -------------------------------------------------------------------------------- /QtChartsDemo/SplineChart/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | QChartView 25 | QGraphicsView 26 |
qchartview.h
27 |
28 |
29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /README.assets/Qt-5.12.12-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/README.assets/Qt-5.12.12-green.png -------------------------------------------------------------------------------- /README.assets/image-20220827211417219.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/README.assets/image-20220827211417219.png -------------------------------------------------------------------------------- /README.assets/个人主页-CSDN-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/README.assets/个人主页-CSDN-orange.png -------------------------------------------------------------------------------- /README.assets/国内站点-gitee-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/README.assets/国内站点-gitee-orange.png -------------------------------------------------------------------------------- /README.assets/国外站点-github-brightgreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/README.assets/国外站点-github-brightgreen.png -------------------------------------------------------------------------------- /Web/CefExamples/LoadWeb/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 本地Html文件 6 | 7 | 8 | 9 |

hello

10 |

world

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Web/CefExamples/LoadWeb/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | #include "QCefSetting.h" 7 | #include "QCefView.h" 8 | 9 | QT_BEGIN_NAMESPACE 10 | namespace Ui { class Widget; } 11 | QT_END_NAMESPACE 12 | 13 | class Widget : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | Widget(QWidget *parent = nullptr); 19 | ~Widget(); 20 | 21 | private: 22 | Ui::Widget *ui; 23 | QCefView* cefViewWidget = nullptr; 24 | }; 25 | #endif // WIDGET_H 26 | -------------------------------------------------------------------------------- /Web/CefExamples/LoadWeb/widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Web/JsonExamples/JsonExamples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += QtJson # qt使用内置json库读写json示例 4 | -------------------------------------------------------------------------------- /Web/JsonExamples/QtJson/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/JsonExamples/QtJson/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | QT_BEGIN_NAMESPACE 13 | namespace Ui { class Widget; } 14 | QT_END_NAMESPACE 15 | 16 | class Widget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | Widget(QWidget *parent = nullptr); 22 | ~Widget(); 23 | 24 | private: 25 | void jsonParse(const QJsonValue& value); 26 | 27 | private slots: 28 | void on_but_create_clicked(); 29 | 30 | void on_but_parse_clicked(); 31 | 32 | void on_but_save_clicked(); 33 | 34 | private: 35 | Ui::Widget *ui; 36 | 37 | QJsonDocument m_doc; // 创建一个用于读写json的对象 38 | }; 39 | #endif // WIDGET_H 40 | -------------------------------------------------------------------------------- /Web/QtWebExamples/authorization/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 在支持的平台上启用Qt中的高DPI缩放 8 | QApplication a(argc, argv); 9 | MainWindow w; 10 | w.show(); 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /Web/QtWebExamples/authorization/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | class QWebEngineView; 7 | 8 | class MainWindow : public QMainWindow 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | MainWindow(QWidget *parent = nullptr); 14 | ~MainWindow(); 15 | 16 | protected: 17 | void on_featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); 18 | 19 | private: 20 | QWebEngineView* m_view = nullptr; 21 | }; 22 | #endif // MAINWINDOW_H 23 | -------------------------------------------------------------------------------- /Web/QtWebExamples/authorization/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | video.html 4 | 5 | 6 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo/web/main.css: -------------------------------------------------------------------------------- 1 | .button { 2 | background-color: #4CAF50; /* Green */ 3 | border: none; 4 | color: white; 5 | padding: 15px 32px; 6 | text-align: center; 7 | text-decoration: none; 8 | display: inline-block; 9 | font-size: 16px; 10 | margin: 4px 2px; 11 | cursor: pointer; 12 | -webkit-transition-duration: 0.4s; /* Safari */ 13 | transition-duration: 0.4s; 14 | box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); 15 | } 16 | .button:hover { 17 | box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19); 18 | } 19 | 20 | #textAreaId { 21 | width: 80%; 22 | height: 100px; 23 | } 24 | 25 | h1 { 26 | font-size: 40px; 27 | color:red; 28 | } 29 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo/web/webClient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web客户端 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Web客户端程序

13 |
14 |
15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo2/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelDemo2/web2/main.css: -------------------------------------------------------------------------------- 1 | .button { 2 | background-color: #4CAF50; /* Green */ 3 | border: none; 4 | color: white; 5 | padding: 15px 32px; 6 | text-align: center; 7 | text-decoration: none; 8 | display: inline-block; 9 | font-size: 14px; 10 | margin: 4px 2px; 11 | cursor: pointer; 12 | -webkit-transition-duration: 0.4s; /* Safari */ 13 | transition-duration: 0.4s; 14 | box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); 15 | } 16 | .button:hover { 17 | box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19); 18 | } 19 | 20 | #textAreaId { 21 | width: 80%; 22 | height: 100px; 23 | } 24 | 25 | h1 { 26 | font-size: 40px; 27 | color:red; 28 | } 29 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelWebSocket/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelWebSocket/swebchannel.cpp: -------------------------------------------------------------------------------- 1 | #include "swebchannel.h" 2 | 3 | SWebChannel::SWebChannel(QObject *parent) : QWebChannel(parent) 4 | { 5 | // 将连接成功的通道传递给QWebChannel 6 | connect(&m_server, &WebSocketServer::newWebSocketTransport, this, &SWebChannel::connectTo); 7 | } 8 | 9 | /** 10 | * @brief 设置WebSocket服务端监听 11 | * @param address 监听的地址 12 | * @param port 监听的端口号 13 | * @return 14 | */ 15 | bool SWebChannel::listen(const QHostAddress &address, quint16 port) 16 | { 17 | // 如果新设置的监听地址、端口和已经监听的相同,则直接返回 18 | if(m_address == address && m_port == port && m_server.isListening()) 19 | { 20 | return true; 21 | } 22 | m_address = address; 23 | m_port = port; 24 | if(m_server.isListening()) // 如果已经在监听了则关闭已有监听,重新监听新的地址、端口 25 | { 26 | m_server.close(); 27 | } 28 | 29 | return m_server.listen(address, port); 30 | } 31 | -------------------------------------------------------------------------------- /Web/QtWebExamples/channelWebSocket/web3/channelClient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | QWebSocket客户端作为QWebChannel通信数据传输接口 6 | 7 | 8 | 9 | 10 | 11 |
12 |

使用QWebSocket客户端作为
QWebChannel通信数据传输接口

13 |

14 | 15 |

16 |

17 | 18 |

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /Web/QtWebExamples/minimal/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 本地Html文件 6 | 7 | 8 | 9 |

hello

10 |

world

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Web/QtWebExamples/minimal/rc.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | hello.html 4 | 5 | 6 | -------------------------------------------------------------------------------- /Web/Web.assets/channelDemo-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/channelDemo-tuya.gif -------------------------------------------------------------------------------- /Web/Web.assets/image-20221211210252527.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221211210252527.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221214171041497.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221214171041497.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221214171147965.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221214171147965.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221215174224272.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221215174224272.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221215175419479.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221215175419479.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221216124021490.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221216124021490.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221217210219249.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221217210219249.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221217210336065.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221217210336065.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221219154051957.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221219154051957.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20221219154652982.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20221219154652982.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20230206155201961.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20230206155201961.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20230206155232023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20230206155232023.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20230206155609104.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20230206155609104.png -------------------------------------------------------------------------------- /Web/Web.assets/image-20230206155736344.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/Web/Web.assets/image-20230206155736344.png -------------------------------------------------------------------------------- /Web/Web.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += QtWebExamples # QWebEngineView、QtWebChannel使用示例 4 | SUBDIRS += JsonExamples # Qt读写Json示例 5 | SUBDIRS += WebSocketsExamples # WebSocket通信示例 6 | SUBDIRS += CefExamples # Qt 嵌入 CEF开发示例 7 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/ChatClient/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/ChatClient/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | 12 | class Widget : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | Widget(QWidget *parent = nullptr); 18 | ~Widget(); 19 | 20 | private slots: 21 | void on_connected(); 22 | void on_disconnected(); 23 | void on_textMessageReceived(const QString &message); 24 | 25 | void on_but_connect_clicked(); 26 | 27 | void on_but_send_clicked(); 28 | 29 | private: 30 | Ui::Widget *ui; 31 | 32 | QWebSocket m_client; 33 | }; 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/ChatClientHtml/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | QApplication a(argc, argv); 10 | 11 | /** 12 | * 使用合适的程序打开url 13 | * QDesktopServices需要使用QApplication才可以执行, 14 | * 否则会报错【QDesktopServices::openUrl: Application is not a GUI application】 15 | */ 16 | qDebug() << QDesktopServices::openUrl(QDir("./html/chatClient.html").absolutePath()); 17 | 18 | return a.exec(); 19 | } 20 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/ChatServer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/ChatServer/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | #include 4 | #include 5 | #include 6 | 7 | QT_BEGIN_NAMESPACE 8 | namespace Ui { class Widget; } 9 | QT_END_NAMESPACE 10 | 11 | class Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | Widget(QWidget *parent = nullptr); 17 | ~Widget(); 18 | 19 | private slots: 20 | void on_newConnection(); 21 | void on_closed(); 22 | void on_textMessageReceived(const QString &message); 23 | void on_disconnected(); 24 | void on_but_listen_clicked(); 25 | 26 | void on_but_send_clicked(); 27 | 28 | private: 29 | Ui::Widget *ui; 30 | 31 | QWebSocketServer* m_server = nullptr; 32 | QList m_clients; 33 | }; 34 | #endif // WIDGET_H 35 | -------------------------------------------------------------------------------- /Web/WebSocketsExamples/WebSocketsExamples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += ChatClient # 使用QWebSocket实现的简单客户端程序 4 | SUBDIRS += ChatServer # 使用QWebSocketServer实现的简单服务端程序 5 | SUBDIRS += ChatClientHtml # 前端网页版本WebSocket客户端程序(html+css+javascript实现) 6 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxabstractooxmlfile_p.h: -------------------------------------------------------------------------------- 1 | // xlsxabstractooxmlfile_p.h 2 | 3 | #ifndef XLSXOOXMLFILE_P_H 4 | #define XLSXOOXMLFILE_P_H 5 | 6 | #include "xlsxglobal.h" 7 | 8 | #include "xlsxabstractooxmlfile.h" 9 | #include "xlsxrelationships_p.h" 10 | 11 | QT_BEGIN_NAMESPACE_XLSX 12 | 13 | class AbstractOOXmlFilePrivate 14 | { 15 | Q_DECLARE_PUBLIC(AbstractOOXmlFile) 16 | 17 | public: 18 | AbstractOOXmlFilePrivate(AbstractOOXmlFile* q, AbstractOOXmlFile::CreateFlag flag); 19 | virtual ~AbstractOOXmlFilePrivate(); 20 | 21 | public: 22 | QString filePathInPackage; //such as "xl/worksheets/sheet1.xml" 23 | 24 | Relationships *relationships; 25 | AbstractOOXmlFile::CreateFlag flag; 26 | AbstractOOXmlFile *q_ptr; 27 | }; 28 | 29 | QT_END_NAMESPACE_XLSX 30 | 31 | #endif // XLSXOOXMLFILE_P_H 32 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxcell_p.h: -------------------------------------------------------------------------------- 1 | // xlsxcell_p.h 2 | 3 | #ifndef XLSXCELL_P_H 4 | #define XLSXCELL_P_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "xlsxglobal.h" 12 | #include "xlsxcell.h" 13 | #include "xlsxcellrange.h" 14 | #include "xlsxrichstring.h" 15 | #include "xlsxcellformula.h" 16 | 17 | QT_BEGIN_NAMESPACE_XLSX 18 | 19 | class CellPrivate 20 | { 21 | Q_DECLARE_PUBLIC(Cell) 22 | public: 23 | CellPrivate(Cell *p); 24 | CellPrivate(const CellPrivate * const cp); 25 | public: 26 | Worksheet *parent; 27 | Cell *q_ptr; 28 | public: 29 | Cell::CellType cellType; 30 | QVariant value; 31 | 32 | CellFormula formula; 33 | Format format; 34 | 35 | RichString richString; 36 | 37 | qint32 styleNumber; 38 | }; 39 | 40 | QT_END_NAMESPACE_XLSX 41 | 42 | #endif // XLSXCELL_P_H 43 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxcellformula_p.h: -------------------------------------------------------------------------------- 1 | // xlsxcellformula_p.h 2 | 3 | #ifndef XLSXCELLFORMULA_P_H 4 | #define XLSXCELLFORMULA_P_H 5 | 6 | #include "xlsxglobal.h" 7 | #include "xlsxcellformula.h" 8 | #include "xlsxcellrange.h" 9 | 10 | #include 11 | #include 12 | 13 | QT_BEGIN_NAMESPACE_XLSX 14 | 15 | class CellFormulaPrivate : public QSharedData 16 | { 17 | public: 18 | CellFormulaPrivate(const QString &formula, const CellRange &reference, CellFormula::FormulaType type); 19 | CellFormulaPrivate(const CellFormulaPrivate &other); 20 | ~CellFormulaPrivate(); 21 | 22 | QString formula; //formula contents 23 | CellFormula::FormulaType type; 24 | CellRange reference; 25 | bool ca; //Calculate Cell 26 | int si; //Shared group index 27 | }; 28 | 29 | QT_END_NAMESPACE_XLSX 30 | 31 | #endif // XLSXCELLFORMULA_P_H 32 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxcelllocation.h: -------------------------------------------------------------------------------- 1 | // xlsxcelllocation.h 2 | 3 | #ifndef CELL_LOCATION_H 4 | #define CELL_LOCATION_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "xlsxglobal.h" 15 | 16 | QT_BEGIN_NAMESPACE_XLSX 17 | 18 | class Cell; 19 | 20 | class CellLocation 21 | { 22 | public: 23 | CellLocation(); 24 | 25 | int col; 26 | int row; 27 | 28 | QSharedPointer cell; 29 | }; 30 | 31 | QT_END_NAMESPACE_XLSX 32 | #endif 33 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxchartsheet_p.h: -------------------------------------------------------------------------------- 1 | // xlsxchartsheet_p.h 2 | 3 | #ifndef XLSXCHARTSHEET_P_H 4 | #define XLSXCHARTSHEET_P_H 5 | 6 | #include 7 | 8 | #include "xlsxglobal.h" 9 | #include "xlsxchartsheet.h" 10 | #include "xlsxabstractsheet_p.h" 11 | 12 | QT_BEGIN_NAMESPACE_XLSX 13 | 14 | class ChartsheetPrivate : public AbstractSheetPrivate 15 | { 16 | Q_DECLARE_PUBLIC(Chartsheet) 17 | public: 18 | ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag); 19 | ~ChartsheetPrivate(); 20 | 21 | Chart *chart; 22 | }; 23 | 24 | QT_END_NAMESPACE_XLSX 25 | #endif // XLSXCHARTSHEET_P_H 26 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxdocpropscore_p.h: -------------------------------------------------------------------------------- 1 | // xlsxdocpropscore_p.h 2 | 3 | #ifndef XLSXDOCPROPSCORE_H 4 | #define XLSXDOCPROPSCORE_H 5 | 6 | #include "xlsxglobal.h" 7 | #include "xlsxabstractooxmlfile.h" 8 | 9 | #include 10 | #include 11 | 12 | class QIODevice; 13 | 14 | QT_BEGIN_NAMESPACE_XLSX 15 | 16 | class DocPropsCore : public AbstractOOXmlFile 17 | { 18 | public: 19 | explicit DocPropsCore(CreateFlag flag); 20 | 21 | bool setProperty(const QString &name, const QString &value); 22 | QString property(const QString &name) const; 23 | QStringList propertyNames() const; 24 | 25 | void saveToXmlFile(QIODevice *device) const; 26 | bool loadFromXmlFile(QIODevice *device); 27 | 28 | private: 29 | QMap m_properties; 30 | }; 31 | 32 | QT_END_NAMESPACE_XLSX 33 | 34 | #endif // XLSXDOCPROPSCORE_H 35 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxdrawing_p.h: -------------------------------------------------------------------------------- 1 | // xlsxdrwaing_p.h 2 | 3 | #ifndef QXLSX_DRAWING_H 4 | #define QXLSX_DRAWING_H 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "xlsxrelationships_p.h" 12 | #include "xlsxabstractooxmlfile.h" 13 | 14 | class QIODevice; 15 | class QXmlStreamWriter; 16 | 17 | QT_BEGIN_NAMESPACE_XLSX 18 | 19 | class DrawingAnchor; 20 | class Workbook; 21 | class AbstractSheet; 22 | class MediaFile; 23 | 24 | class Drawing : public AbstractOOXmlFile 25 | { 26 | public: 27 | Drawing(AbstractSheet *sheet, CreateFlag flag); 28 | ~Drawing(); 29 | void saveToXmlFile(QIODevice *device) const; 30 | bool loadFromXmlFile(QIODevice *device); 31 | 32 | AbstractSheet *sheet; 33 | Workbook *workbook; 34 | QList anchors; 35 | }; 36 | 37 | QT_END_NAMESPACE_XLSX 38 | 39 | #endif // QXLSX_DRAWING_H 40 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxglobal.h: -------------------------------------------------------------------------------- 1 | // xlsxglobal.h 2 | 3 | #ifndef XLSXGLOBAL_H 4 | #define XLSXGLOBAL_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx { 20 | #define QT_END_NAMESPACE_XLSX } 21 | 22 | #define QXLSX_USE_NAMESPACE using namespace QXlsx; 23 | 24 | #if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) 25 | #undef QT_BEGIN_MOC_NAMESPACE 26 | #undef QT_END_MOC_NAMESPACE 27 | #define QT_BEGIN_MOC_NAMESPACE namespace QXlsx { 28 | #define QT_END_MOC_NAMESPACE } 29 | #define QStringLiteral QLatin1String 30 | #define Q_DECL_NOTHROW 31 | #endif 32 | 33 | #endif // XLSXGLOBAL_H 34 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxtheme_p.h: -------------------------------------------------------------------------------- 1 | // xlsxtheme_p.h 2 | 3 | #ifndef XLSXTHEME_H 4 | #define XLSXTHEME_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "xlsxabstractooxmlfile.h" 11 | 12 | QT_BEGIN_NAMESPACE_XLSX 13 | 14 | class Theme : public AbstractOOXmlFile 15 | { 16 | public: 17 | Theme(CreateFlag flag); 18 | 19 | void saveToXmlFile(QIODevice *device) const; 20 | QByteArray saveToXmlData() const; 21 | bool loadFromXmlData(const QByteArray &data); 22 | bool loadFromXmlFile(QIODevice *device); 23 | 24 | QByteArray xmlData; 25 | }; 26 | 27 | QT_END_NAMESPACE_XLSX 28 | 29 | #endif // XLSXTHEME_H 30 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/header/xlsxzipwriter_p.h: -------------------------------------------------------------------------------- 1 | // xlsxzipwriter_p.h 2 | 3 | #ifndef QXLSX_ZIPWRITER_H 4 | #define QXLSX_ZIPWRITER_H 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "xlsxglobal.h" 11 | 12 | class QZipWriter; 13 | 14 | QT_BEGIN_NAMESPACE_XLSX 15 | 16 | class ZipWriter 17 | { 18 | public: 19 | explicit ZipWriter(const QString &filePath); 20 | explicit ZipWriter(QIODevice *device); 21 | ~ZipWriter(); 22 | 23 | void addFile(const QString &filePath, QIODevice *device); 24 | void addFile(const QString &filePath, const QByteArray &data); 25 | bool error() const; 26 | void close(); 27 | 28 | private: 29 | QZipWriter *m_writer; 30 | }; 31 | 32 | QT_END_NAMESPACE_XLSX 33 | 34 | #endif // QXLSX_ZIPWRITER_H 35 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/source/xlsxcelllocation.cpp: -------------------------------------------------------------------------------- 1 | // xlsxcelllocation.cpp 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "xlsxglobal.h" 10 | #include "xlsxcell.h" 11 | #include "xlsxcelllocation.h" 12 | 13 | QT_BEGIN_NAMESPACE_XLSX 14 | 15 | CellLocation::CellLocation() 16 | { 17 | col = -1; 18 | row = -1; 19 | 20 | cell.clear(); 21 | } 22 | 23 | QT_END_NAMESPACE_XLSX 24 | -------------------------------------------------------------------------------- /XlsxDemo/QXlsx/source/xlsxsimpleooxmlfile.cpp: -------------------------------------------------------------------------------- 1 | // xlsxsimpleooxmlfile.cpp 2 | 3 | #include "xlsxsimpleooxmlfile_p.h" 4 | 5 | #include 6 | #include 7 | 8 | QT_BEGIN_NAMESPACE_XLSX 9 | 10 | SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag) 11 | :AbstractOOXmlFile(flag) 12 | { 13 | } 14 | 15 | void SimpleOOXmlFile::saveToXmlFile(QIODevice *device) const 16 | { 17 | device->write(xmlData); 18 | } 19 | 20 | QByteArray SimpleOOXmlFile::saveToXmlData() const 21 | { 22 | return xmlData; 23 | } 24 | 25 | bool SimpleOOXmlFile::loadFromXmlData(const QByteArray &data) 26 | { 27 | xmlData = data; 28 | return true; 29 | } 30 | 31 | bool SimpleOOXmlFile::loadFromXmlFile(QIODevice *device) 32 | { 33 | xmlData = device->readAll(); 34 | return true; 35 | } 36 | 37 | QT_END_NAMESPACE_XLSX 38 | -------------------------------------------------------------------------------- /XlsxDemo/TestXlsx/Interface.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERFACE_H 2 | #define INTERFACE_H 3 | 4 | #include 5 | 6 | 7 | class InterFace : public QWidget 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | explicit InterFace(QWidget *parent = nullptr) :QWidget(parent){} 13 | virtual ~InterFace(){} 14 | /** 15 | * @brief 返回当前类中用到的Excel的名称 16 | * @return 17 | */ 18 | virtual QString getExcelName() = 0; 19 | }; 20 | 21 | #endif // INTERFACE_H 22 | -------------------------------------------------------------------------------- /XlsxDemo/TestXlsx/TestXlsx.pri: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------- 2 | # 功能: Qt使用QXlsx读写Excel 3 | # 编译器: 4 | # 5 | # @开发者 mhf 6 | # @邮箱 1603291350@qq.com 7 | # @时间 2022/04/14 8 | # @备注 9 | #--------------------------------------------------------- 10 | FORMS += \ 11 | $$PWD/test1.ui \ 12 | $$PWD/test2.ui \ 13 | $$PWD/test3.ui \ 14 | $$PWD/test4.ui \ 15 | $$PWD/test5.ui \ 16 | $$PWD/test6.ui \ 17 | $$PWD/test7.ui 18 | 19 | HEADERS += \ 20 | $$PWD/Interface.h \ 21 | $$PWD/test1.h \ 22 | $$PWD/test2.h \ 23 | $$PWD/test3.h \ 24 | $$PWD/test4.h \ 25 | $$PWD/test5.h \ 26 | $$PWD/test6.h \ 27 | $$PWD/test7.h 28 | 29 | SOURCES += \ 30 | $$PWD/test1.cpp \ 31 | $$PWD/test2.cpp \ 32 | $$PWD/test3.cpp \ 33 | $$PWD/test4.cpp \ 34 | $$PWD/test5.cpp \ 35 | $$PWD/test6.cpp \ 36 | $$PWD/test7.cpp 37 | -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/image-20220629154430927.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/image-20220629154430927.png -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/image-20220629154520501.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/image-20220629154520501.png -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/image-20220629154549163.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/image-20220629154549163.png -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/image-20220712163106069.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/image-20220712163106069.png -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/image-20220712163125370.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/image-20220712163125370.png -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/qxlsx1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/qxlsx1.gif -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/shee.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/shee.gif -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/state.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/state.gif -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/test5-tuya.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/test5-tuya.gif -------------------------------------------------------------------------------- /XlsxDemo/XlsxDemo.assets/test6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/XlsxDemo.assets/test6.gif -------------------------------------------------------------------------------- /XlsxDemo/appendix.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/C++.PNG 4 | image/Qt.PNG 5 | 6 | 7 | -------------------------------------------------------------------------------- /XlsxDemo/image/C++.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/image/C++.PNG -------------------------------------------------------------------------------- /XlsxDemo/image/Qt.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahuifa/QMDemo/24f50b8641c9f2b30c6e57e5e4bc623a8289f111/XlsxDemo/image/Qt.PNG -------------------------------------------------------------------------------- /XlsxDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | Widget w; 9 | w.show(); 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /XlsxDemo/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Widget; } 8 | QT_END_NAMESPACE 9 | 10 | class Widget : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | Widget(QWidget *parent = nullptr); 16 | ~Widget(); 17 | 18 | private: 19 | 20 | private slots: 21 | 22 | void on_but_show_clicked(); 23 | 24 | private: 25 | Ui::Widget *ui; 26 | }; 27 | #endif // WIDGET_H 28 | --------------------------------------------------------------------------------