├── .gitignore ├── .gitmodules ├── CustomQch ├── CustomQch.pro ├── Doxyfile ├── doxygen-qmi-style │ ├── README.md │ ├── footer.html │ ├── header.html │ ├── navtree │ │ ├── ftv2mlastnode.png │ │ ├── ftv2mnode.png │ │ ├── ftv2plastnode.png │ │ ├── ftv2pnode.png │ │ └── navtree.css │ ├── qmi.css │ └── search │ │ └── search.css ├── ifmetwindow.cpp ├── ifmetwindow.h ├── ifmetwindow.ui └── main.cpp ├── DbSigSlot ├── CMakeLists.txt ├── db_object.cpp ├── main.cpp ├── object.cpp └── object.h ├── DeDuplication ├── DeDuplication.sln ├── DeDuplication │ ├── DeDuplication.cpp │ ├── DeDuplication.h │ ├── DeDuplication.vcxproj │ ├── DeDuplication.vcxproj.filters │ └── main.cpp └── Unique │ ├── Unique.cpp │ ├── Unique.vcxproj │ └── Unique.vcxproj.filters ├── ExCRLF ├── CMakeLists.txt ├── bin │ └── ExCRLF.txt └── main.cpp ├── ExChangeSVGColor ├── .gitignore ├── CMakeLists.txt ├── README.md ├── display.gif ├── main.cpp ├── mosaic.svg ├── resource.qrc ├── widget.cpp └── widget.h ├── ExIntelDete ├── CMakeLists.txt ├── main.cpp ├── widget.cpp └── widget.h ├── ExPicShot ├── .gitignore ├── CMakeLists.txt ├── main.cpp ├── widget.cpp └── widget.h ├── ExThreadSafety └── multithread.h ├── LICENSE ├── QToolButtonAutoRaiseEx ├── CMakeAutoRaise │ ├── .gitignore │ ├── CMakeLists.txt │ ├── icons │ │ ├── normal │ │ │ ├── arrow.svg │ │ │ ├── copy.svg │ │ │ ├── download.svg │ │ │ ├── ellipse.svg │ │ │ ├── exit.svg │ │ │ ├── fill-ellipse.svg │ │ │ ├── fill-rect.svg │ │ │ ├── gif.svg │ │ │ ├── line.svg │ │ │ ├── mosaic.svg │ │ │ ├── pen.svg │ │ │ ├── recover.svg │ │ │ ├── rectangle.svg │ │ │ ├── revoke.svg │ │ │ ├── right.svg │ │ │ ├── screenshot.svg │ │ │ ├── text.svg │ │ │ └── update.svg │ │ └── tool │ │ │ ├── arrow.svg │ │ │ ├── cancel.svg │ │ │ ├── ellipse.svg │ │ │ ├── finish.svg │ │ │ ├── gif.svg │ │ │ ├── mosaic.svg │ │ │ ├── pen.svg │ │ │ ├── pin.svg │ │ │ ├── rectangle.svg │ │ │ ├── renewal.svg │ │ │ ├── revocation.svg │ │ │ ├── save.svg │ │ │ ├── serialnumber.svg │ │ │ ├── smooth.svg │ │ │ └── text.svg │ ├── main.cpp │ ├── resources.qrc │ ├── testbtstyle.cpp │ ├── testbtstyle.h │ ├── widget.cpp │ └── widget.h └── QMakeAutoRaise │ ├── .gitignore │ ├── QMakeAutoRaise.pro │ ├── icons │ ├── normal │ │ ├── arrow.svg │ │ ├── copy.svg │ │ ├── download.svg │ │ ├── ellipse.svg │ │ ├── exit.svg │ │ ├── fill-ellipse.svg │ │ ├── fill-rect.svg │ │ ├── gif.svg │ │ ├── line.svg │ │ ├── mosaic.svg │ │ ├── pen.svg │ │ ├── recover.svg │ │ ├── rectangle.svg │ │ ├── revoke.svg │ │ ├── right.svg │ │ ├── screenshot.svg │ │ ├── text.svg │ │ └── update.svg │ └── tool │ │ ├── arrow.svg │ │ ├── cancel.svg │ │ ├── ellipse.svg │ │ ├── finish.svg │ │ ├── gif.svg │ │ ├── mosaic.svg │ │ ├── pen.svg │ │ ├── pin.svg │ │ ├── rectangle.svg │ │ ├── renewal.svg │ │ ├── revocation.svg │ │ ├── save.svg │ │ ├── serialnumber.svg │ │ ├── smooth.svg │ │ └── text.svg │ ├── main.cpp │ ├── resources.qrc │ ├── testbtstyle.cpp │ ├── testbtstyle.h │ ├── widget.cpp │ └── widget.h ├── QtComboModeShow ├── QtComboModeShow.pro └── main.cpp ├── QtConnect ├── QtConnect.pro ├── main.cpp ├── widget.cpp └── widget.h ├── QtCustomDialogEx ├── ExCustomMainWin.cpp ├── ExCustomMainWin.h ├── ExCustomMainWin.ui ├── ExDlgLocate.cpp ├── ExDlgLocate.h ├── ExDlgLocate.ui ├── ExDlgSetHeaders.cpp ├── ExDlgSetHeaders.h ├── ExDlgSetHeaders.ui ├── ExDlgSize.cpp ├── ExDlgSize.h ├── ExDlgSize.ui ├── QtCustomDialogEx.pro ├── images │ ├── Image001.png │ ├── Image002.png │ ├── Image003.png │ ├── Image004.jpg │ ├── Image005.png │ ├── Image006.png │ └── Image007.png ├── main.cpp ├── qt.ico └── resources.qrc ├── QtCustomTypeAndQMetaType ├── QtCustomTypeAndQMetaType.pro └── main.cpp ├── QtDateTimeEx ├── ExDateTime.cpp ├── ExDateTime.h ├── ExDateTime.ui ├── QtDateTimeEx.pro ├── main.cpp └── qt.ico ├── QtEvent ├── QtEvent.pro └── main.cpp ├── QtHttpEx ├── ExHttp.cpp ├── ExHttp.h ├── ExHttp.ui ├── QtHttpEx.pro ├── images │ ├── Image1.png │ ├── Image2.jpg │ ├── Image3.png │ ├── Image4.png │ ├── Image5.png │ ├── Image6.png │ ├── icon.icns │ └── icon.ico ├── main.cpp └── resources.qrc ├── QtMDIEx ├── ExMDI.cpp ├── ExMDI.h ├── ExMDI.ui ├── ExMainWindow.cpp ├── ExMainWindow.h ├── ExMainWindow.ui ├── QtMDIEx.pro ├── images │ ├── .DS_Store │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.jpg │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.jpg │ ├── 7.png │ ├── 8.png │ └── 9.png ├── main.cpp └── resources.qrc ├── QtMeatObjectEx ├── ExPerson.cpp ├── ExPerson.h ├── ExWidget.cpp ├── ExWidget.h ├── ExWidget.ui ├── QtMeatObjectEx.pro ├── main.cpp └── qt.ico ├── QtMetaAboutClass ├── QtMetaAboutClass.pro ├── m.h └── main.cpp ├── QtMyStyleEx ├── .gitignore ├── QtExample01 │ └── QtStyleEx │ │ ├── QtStyleEx.pro │ │ ├── main.cpp │ │ ├── widget.cpp │ │ └── widget.h ├── QtExample02 │ └── QtStyleEx │ │ ├── QtStyleEx.pro │ │ ├── main.cpp │ │ ├── mystyle.cpp │ │ ├── mystyle.h │ │ ├── widget.cpp │ │ └── widget.h └── QtExample03 │ └── QtStyleEx │ ├── QtStyleEx.pro │ ├── main.cpp │ ├── mystyle.cpp │ ├── mystyle.h │ ├── myswitchbutton.cpp │ ├── myswitchbutton.h │ ├── myswitchbutton_p.h │ ├── widget.cpp │ └── widget.h ├── QtObjectTree ├── QtObjectTree.pro └── main.cpp ├── QtProperty ├── QtProperty.pro ├── m.h └── main.cpp ├── QtQDialogEx ├── ExDialog.cpp ├── ExDialog.h ├── ExDialog.ui ├── QtQDialogEx.pro ├── main.cpp └── qt.ico ├── QtQFileSystemModelEx ├── ExQFileSystemModel.cpp ├── ExQFileSystemModel.h ├── ExQFileSystemModel.ui ├── QtQFileSystemModelEx.pro ├── main.cpp └── qt.ico ├── QtQHostInfoEx ├── ExQHostInfo.cpp ├── ExQHostInfo.h ├── ExQHostInfo.ui ├── Icon.icns ├── QtQHostInfoEx.pro ├── icon.ico └── main.cpp ├── QtQMetaProperty ├── QtQMetaProperty.pro ├── m.h └── main.cpp ├── QtQProgressBarEx ├── ExQProgressBar.cpp ├── ExQProgressBar.h ├── ExQProgressBaressBarressbar.ui ├── QtQProgressBarEx.pro ├── main.cpp └── qt.ico ├── QtQSliderEx ├── ExQSlider.cpp ├── ExQSlider.h ├── ExQSlider.ui ├── QtQSliderEx.pro ├── main.cpp └── qt.ico ├── QtQStandardItemModelEx ├── ExDelegate.cpp ├── ExDelegate.h ├── ExQStandardItemModel.cpp ├── ExQStandardItemModel.h ├── ExQStandardItemModel.ui ├── QtQStandardItemModelEx.pro ├── images │ ├── Image001.png │ ├── Image002.png │ ├── Image003.png │ ├── Image004.png │ ├── Image005.png │ ├── Image006.png │ ├── Image007.jpg │ ├── Image008.jpg │ ├── Image009.jpg │ ├── Image010.jpg │ ├── Image011.jpg │ └── Image012.png ├── main.cpp ├── qt.ico ├── resources.qrc └── 录入的人员信息.txt ├── QtQStringEx ├── ExQString.cpp ├── ExQString.h ├── ExQString.ui ├── QtQStringEx.pro ├── main.cpp └── qt.ico ├── QtQStringFunEx ├── ExQStringFun.cpp ├── ExQStringFun.h ├── ExQStringFun.ui ├── QtQStringFunEx.pro ├── main.cpp └── qt.ico ├── QtQStringListModelEx ├── ExQStringListModel.cpp ├── ExQStringListModel.h ├── ExQStringListModel.ui ├── QtQStringListModelEx.pro └── main.cpp ├── QtQTableWidgetEx ├── ExQTableWidget.cpp ├── ExQTableWidget.h ├── ExQTableWidget.ui ├── QtQTableWidgetEx.pro ├── images │ ├── Image002.ico │ └── Image003.ico ├── main.cpp ├── qt.ico └── resoure.qrc ├── QtQTreeWidgetEx ├── ExQTreeWidget.cpp ├── ExQTreeWidget.h ├── ExQTreeWidget.ui ├── QtQTreeWidgetEx.pro ├── image │ ├── Image001.jpg │ ├── Image002.jpg │ ├── Image003.jpg │ ├── Image004.jpg │ ├── Image005.jpg │ ├── Image006.jpg │ ├── Image007.jpg │ ├── Image008.jpg │ ├── Image009.jpg │ ├── Image010.jpg │ ├── Image011.jpg │ ├── Image012.jpg │ ├── Image013.ico │ ├── Image014.jpg │ ├── Image015.jpg │ └── Image016.jpg ├── main.cpp ├── qt.ico └── resources.qrc ├── QtQVariant ├── QtQVariant.pro └── main.cpp ├── QtQ_OBJECT ├── QtQ_OBJECT.pro ├── m.cpp ├── m.h └── main.cpp ├── QtQcomboBoxEx ├── ExQcomboBox.cpp ├── ExQcomboBox.h ├── ExQcomboBox.ui ├── QtQcomboBoxEx.pro ├── images │ ├── github.ico │ ├── gril.ico │ └── qt.ico ├── main.cpp └── resources.qrc ├── QtQdialQLCDEx ├── ExQdialQLCD.cpp ├── ExQdialQLCD.h ├── ExQdialQLCD.ui ├── QtQdialQLCDEx.pro ├── main.cpp └── qt.ico ├── QtQlistWidgetEx ├── ExQListWidget.cpp ├── ExQListWidget.h ├── ExQListWidget.ui ├── QtQlistWidgetEx.pro ├── images │ ├── List.png │ ├── TREE.png │ ├── Table.png │ ├── add.png │ ├── clear.png │ ├── delete.png │ ├── exit.png │ ├── github.png │ ├── gril.png │ ├── init.png │ ├── insert.png │ └── menu.png ├── main.cpp ├── qt.ico └── resources.qrc ├── QtSigSlot ├── QtSigSlot.pro ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h └── mainwindow.ui ├── QtTcpEx ├── ExTcpClient │ ├── ExTcpClient.cpp │ ├── ExTcpClient.h │ ├── ExTcpClient.pro │ ├── ExTcpClient.ui │ ├── images │ │ ├── Image1.png │ │ ├── Image2.jpg │ │ ├── Image3.png │ │ ├── Image4.png │ │ ├── Image5.png │ │ ├── Image6.png │ │ ├── icon.icns │ │ └── icon.ico │ ├── main.cpp │ └── resource.qrc └── ExTcpServer │ ├── ExTcpServer.cpp │ ├── ExTcpServer.h │ ├── ExTcpServer.pro │ ├── ExTcpServer.ui │ ├── images │ ├── Image1.png │ ├── Image2.jpg │ ├── Image3.png │ ├── Image4.png │ ├── Image5.png │ ├── Image6.png │ ├── icon.icns │ ├── icon.ico │ └── resources.qrc │ └── main.cpp ├── QtUdpEx ├── ExMulticast │ ├── ExMulticast.cpp │ ├── ExMulticast.h │ ├── ExMulticast.pro │ ├── ExMulticast.ui │ ├── images │ │ ├── Image1.png │ │ ├── Image2.jpg │ │ ├── Image3.png │ │ ├── Image4.png │ │ ├── Image5.png │ │ ├── Image6.png │ │ ├── icon.icns │ │ └── icon.ico │ ├── main.cpp │ └── resources.qrc └── ExTrans │ ├── ExTrans.cpp │ ├── ExTrans.h │ ├── ExTrans.pro │ ├── ExTrans.ui │ ├── images │ ├── Image1.png │ ├── Image2.jpg │ ├── Image3.png │ ├── Image4.png │ ├── Image5.png │ ├── Image6.png │ ├── icon.icns │ └── icon.ico │ ├── main.cpp │ └── resources.qrc ├── README.md ├── Studio ├── DesignPatterns │ ├── AbstractFactory.cpp │ ├── AbstractFactory.h │ ├── DesignPatterns.cpp │ ├── DesignPatterns.vcxproj │ ├── DesignPatterns.vcxproj.filters │ ├── FactoryMethod.cpp │ ├── FactoryMethod.h │ ├── Observer.cpp │ ├── Observer.h │ ├── Singleton.cpp │ └── Singleton.h ├── Studio.sln └── Studio │ ├── BinarySearch.cpp │ ├── BinarySearch.h │ ├── MemoryAlignment.h │ ├── SharedPtr.cpp │ ├── SharedPtr.h │ ├── SpecialMembers.cpp │ ├── SpecialMembers.h │ ├── Studio.cpp │ ├── Studio.vcxproj │ ├── Studio.vcxproj.filters │ ├── UniquePtr.cpp │ └── UniquePtr.h ├── TestHotKey ├── CMakeLists.txt ├── QHotkey │ ├── QHotkey │ ├── QHotkey.pro │ ├── qhotkey.cpp │ ├── qhotkey.h │ ├── qhotkey.pri │ ├── qhotkey_mac.cpp.BAK │ ├── qhotkey_p.h │ ├── qhotkey_win.cpp │ └── qhotkey_x11.cpp.BAK ├── Resources.qrc ├── main.cpp ├── resources │ └── PicShot_32.svg ├── tray.cpp ├── tray.h ├── widget.cpp └── widget.h ├── WINDOWS_MSVC_MinGW & LINUX_GCC & MACOS_CLANG 所遇到奇葩问题集锦.md ├── tools └── qt5.natvis └── www.regexlab.com_zh_encoding.htm.png /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ExPicShot/3rdparty/spdlog"] 2 | path = ExPicShot/3rdparty/spdlog 3 | url = https://github.com/gabime/spdlog.git 4 | -------------------------------------------------------------------------------- /CustomQch/CustomQch.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2021-03-08T15:28:01 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = CustomQch 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ifmetwindow.cpp 30 | 31 | HEADERS += \ 32 | ifmetwindow.h 33 | 34 | FORMS += \ 35 | ifmetwindow.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/README.md: -------------------------------------------------------------------------------- 1 | Qmi is a "**Q**t **Mi**nimal" theme for the Doxygen HTML documentation. 2 | It based on official Qt4 documentation's style. 3 | 4 | # How to setup 5 | 6 | To use `qmi` style make the following changes in your Doxyfile: 7 | 8 | # Project section 9 | BRIEF_MEMBER_DESC = NO 10 | 11 | # HTML section 12 | HTML_HEADER = ${path_to_qmi}/header.html 13 | HTML_FOOTER = ${path_to_qmi}/footer.html 14 | HTML_STYLESHEET = ${path_to_qmi}/qmi.css 15 | 16 | **NOTE**: 17 | 18 | * If you use **_tree navigation panel_** then copy contents of the `navtree` dir to the documentation html dir. 19 | * If you use **_search_** feature then copy contents of the `search` dir to the `html/search`. 20 | 21 | # Examples 22 | 23 | If you want to see `qmi` style in action then use the following links with examples: 24 | 25 | * [Qwt docs](http://skozlovf.github.com/doxygen-qmi-style/qwt) 26 | * [libxml++ docs](http://skozlovf.github.com/doxygen-qmi-style/libxmlpp) (with tree navigation and search) 27 | 28 | 29 | ## Screenshots 30 | 31 | * **Main page**: 32 | 33 | ![](http://skozlovf.github.com/doxygen-qmi-style/shot1.png) 34 | 35 | * **Index page**: 36 | 37 | ![](http://skozlovf.github.com/doxygen-qmi-style/shot2.png) 38 | 39 | * **Member description**: 40 | 41 | ![](http://skozlovf.github.com/doxygen-qmi-style/shot3.png) 42 | -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | qmi style 11 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/navtree/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/CustomQch/doxygen-qmi-style/navtree/ftv2mlastnode.png -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/navtree/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/CustomQch/doxygen-qmi-style/navtree/ftv2mnode.png -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/navtree/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/CustomQch/doxygen-qmi-style/navtree/ftv2plastnode.png -------------------------------------------------------------------------------- /CustomQch/doxygen-qmi-style/navtree/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/CustomQch/doxygen-qmi-style/navtree/ftv2pnode.png -------------------------------------------------------------------------------- /CustomQch/ifmetwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ifmetwindow.h" 2 | #include "ui_ifmetwindow.h" 3 | 4 | /*! 5 | * \brief IfmetWindow::IfmetWindow 我的构造函数 6 | * \param parent 7 | */ 8 | IfmetWindow::IfmetWindow(QWidget *parent) : 9 | QMainWindow(parent), 10 | ui(new Ui::IfmetWindow) 11 | { 12 | ui->setupUi(this); 13 | } 14 | 15 | /*! 16 | * \brief IfmetWindow::~IfmetWindow 我的析构函数 17 | */ 18 | IfmetWindow::~IfmetWindow() 19 | { 20 | delete ui; 21 | } 22 | -------------------------------------------------------------------------------- /CustomQch/ifmetwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef IFMETWINDOW_H 2 | #define IFMETWINDOW_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class IfmetWindow; 8 | } 9 | 10 | class IfmetWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit IfmetWindow(QWidget *parent = nullptr); 16 | ~IfmetWindow(); 17 | 18 | private: 19 | Ui::IfmetWindow *ui; 20 | }; 21 | 22 | #endif // IFMETWINDOW_H 23 | -------------------------------------------------------------------------------- /CustomQch/ifmetwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | IfmetWindow 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | IfmetWindow 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CustomQch/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ifmetwindow.h" 2 | #include 3 | 4 | /* 5 | * Copyright (C) 2021 偕臧 All rights reserved. 6 | * 7 | * Author: 偕臧 8 | * github: https://github.com/xmuli 9 | * blogs: https://ifmet.cn 10 | * 11 | * 一个自定义 Qt Assistants 的文档例子,写于 2021-03-08 12 | */ 13 | 14 | /*! 15 | * \brief main 所有函数的入口 16 | * \param argc 参数个数 17 | * \param argv 参数地址(二维) 18 | * \return 程序运行状态 19 | */ 20 | int main(int argc, char *argv[]) 21 | { 22 | QApplication a(argc, argv); 23 | IfmetWindow w; 24 | w.show(); 25 | 26 | return a.exec(); 27 | } 28 | -------------------------------------------------------------------------------- /DbSigSlot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(DbSigSlot) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | add_executable(DbSigSlot main.cpp object.cpp object.h db_object.cpp) 7 | -------------------------------------------------------------------------------- /DbSigSlot/db_object.cpp: -------------------------------------------------------------------------------- 1 | #include "object.h" 2 | 3 | //db_object: 是由 moc 编译器 将 object.cpp 展开的内容(此处手写表示) 4 | 5 | const char sig_names[] = "sig1()"; 6 | const char slot_names[] = "slot1()"; 7 | MetaObject Object::meta = {sig_names, slot_names}; 8 | 9 | void Object::sig1() 10 | { 11 | MetaObject::active(this, 0); 12 | } 13 | 14 | void Object::slot1() 15 | { 16 | cout << "-----------> this is slot1()"; 17 | } 18 | 19 | // 槽的索引==> 槽函数 20 | void Object::metacall(int idx) 21 | { 22 | switch (idx) { 23 | case 0: 24 | slot1(); 25 | break; 26 | default: 27 | break; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DbSigSlot/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "object.h" 3 | using namespace std; 4 | 5 | // 目的:自行构造 moc 编译器,手动将 object.h --> db_bject.cpp (宏 和 moc 编译器处理的部分) 6 | // 时间:2021-003-26 7 | // 作者:偕臧 ifmet.cn 8 | // 下载:https://github.com/xmuli/QtExamples 9 | // 参考:https://blog.csdn.net/perfectguyipeng/article/details/78082360 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | Object *obj1 = new Object(); 14 | Object *obj2 = new Object(); 15 | 16 | Object::db_connet(obj1, "sig1()", obj2, "slot1()"); 17 | obj1->testSignal(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /DbSigSlot/object.cpp: -------------------------------------------------------------------------------- 1 | #include "object.h" 2 | #include 3 | 4 | static int findSignalIndex(const char *str, const char *subStr) 5 | { 6 | if (!str || !subStr || strlen(str) < strlen(subStr)) 7 | return -1; 8 | 9 | int ret = strcmp(str, subStr); 10 | if (ret == 0) 11 | return ret; 12 | else 13 | return -1; 14 | 15 | } 16 | 17 | void Object::db_connet(Object *sender, const char *sig, Object *receiver, const char *slot) 18 | { 19 | int sig_idx = findSignalIndex(sender->meta.sig_names, sig); 20 | int slot_idx = findSignalIndex(receiver->meta.slot_names, slot); 21 | 22 | if (sig_idx == -1 || slot_idx == -1) { 23 | cout<<"signal or slot not found!"; 24 | return; 25 | } else { 26 | Connection c = {receiver, slot_idx}; 27 | sender->connectionsMap.insert(pair(sig_idx, c)); // connectionsMap 私有成员 28 | } 29 | } 30 | 31 | void Object::testSignal() 32 | { 33 | db_emit sig1(); 34 | } 35 | 36 | Object::Object() 37 | { 38 | 39 | } 40 | 41 | Object::~Object() 42 | { 43 | 44 | } 45 | 46 | // 通过 sender 的信号 idx ==> 槽函数 47 | void MetaObject::active(Object *sender, int idx) 48 | { 49 | pair ret; 50 | ret = sender->connectionsMap.equal_range(idx); // 寻找[idx, ) 51 | for (ConnectionMapIt it = ret.first; it != ret.second; ++it) { 52 | Connection c = (*it).second; 53 | c.recviver->metacall(idx); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /DbSigSlot/object.h: -------------------------------------------------------------------------------- 1 | #ifndef OBJECT_H 2 | #define OBJECT_H 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | #define db_signals protected 9 | #define db_slots 10 | #define db_emit 11 | 12 | class Object; 13 | struct MetaObject // 元对象 14 | { 15 | const char *sig_names; 16 | const char *slot_names; 17 | 18 | static void active(Object *sender, int idx); 19 | }; 20 | 21 | struct Connection 22 | { 23 | Object *recviver; 24 | int method; 25 | }; 26 | 27 | typedef multimap ConnectionMap; 28 | typedef multimap::iterator ConnectionMapIt; 29 | 30 | class Object 31 | { 32 | static MetaObject meta; 33 | void metacall(int idx); 34 | 35 | public: 36 | static void db_connet(Object *sender, const char *sig, Object *receiver, const char *slot); 37 | void testSignal(); 38 | 39 | public: 40 | Object(); 41 | virtual ~Object(); 42 | 43 | db_signals: 44 | void sig1(); 45 | // void sig2(); 46 | 47 | public db_slots: 48 | void slot1(); 49 | // void slot2(); 50 | 51 | friend class MetaObject; 52 | private: 53 | ConnectionMap connectionsMap; 54 | }; 55 | 56 | #endif // OBJECT_H 57 | -------------------------------------------------------------------------------- /DeDuplication/DeDuplication/DeDuplication.cpp: -------------------------------------------------------------------------------- 1 | #include "DeDuplication.h" 2 | -------------------------------------------------------------------------------- /DeDuplication/DeDuplication/DeDuplication.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/DeDuplication/DeDuplication/DeDuplication.h -------------------------------------------------------------------------------- /DeDuplication/DeDuplication/DeDuplication.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /DeDuplication/DeDuplication/main.cpp: -------------------------------------------------------------------------------- 1 | // DeDuplication.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | #include "DeDuplication.h" 6 | 7 | int main() 8 | { 9 | DeDuplication deDup; 10 | deDup.finally(); 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /DeDuplication/Unique/Unique.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/DeDuplication/Unique/Unique.cpp -------------------------------------------------------------------------------- /DeDuplication/Unique/Unique.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /ExCRLF/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(ExCRLF LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | set(CMAKE_AUTOUIC ON) 8 | set(CMAKE_AUTOMOC ON) 9 | set(CMAKE_AUTORCC ON) 10 | 11 | set(CMAKE_CXX_STANDARD 11) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) 15 | find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) 16 | 17 | add_executable(ExCRLF 18 | main.cpp 19 | ) 20 | target_link_libraries(ExCRLF Qt${QT_VERSION_MAJOR}::Core) 21 | -------------------------------------------------------------------------------- /ExCRLF/bin/ExCRLF.txt: -------------------------------------------------------------------------------- 1 | (abcdefg1234hijk) [FOXES](abcdefg1234hijk) 2 | [FOXES](abcdefg1234hijk) 3 | [FOXES](abcdefg1234hijk) 4 | [FOXES] -------------------------------------------------------------------------------- /ExChangeSVGColor/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /ExChangeSVGColor/README.md: -------------------------------------------------------------------------------- 1 | ### 效果:修改 `.svg` 的图片颜色,且不模糊(保持相同大小) 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ExChangeSVGColor/display.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/ExChangeSVGColor/display.gif -------------------------------------------------------------------------------- /ExChangeSVGColor/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | QApplication a(argc, argv); 15 | Widget w; 16 | w.show(); 17 | 18 | 19 | // QVector> vLab; 20 | // vLab.append(QMap({"labRed", "#DB000F"})); 21 | // vLab.append(QMap({"labYellow", "#FFCF53"})); 22 | // vLab.append(QMap({"labGreen", "#12F63B"})); 23 | // vLab.append(QMap({"labBlue", "#0E70FF"})); 24 | // vLab.append(QMap({"labPink", "#FB4288"})); 25 | // vLab.append(QMap({"labBlack", "#323232"})); 26 | // vLab.append(QMap({"labWhite", "#FBFBFB"})); 27 | // vLab.append(QMap({"labPick", "#FFDB34"})); // 28 | 29 | // qDebug() << vLab[2].first() << " "; 30 | 31 | 32 | // QPushButton* btn = new QPushButton("btn123"); 33 | // QIcon icon("D:/projects/PicShot/src/resourcesicons/normal/gif.svg"); 34 | // btn->setIcon(icon); 35 | // btn->show(); 36 | return a.exec(); 37 | } 38 | -------------------------------------------------------------------------------- /ExChangeSVGColor/mosaic.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ExChangeSVGColor/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | mosaic.svg 4 | 5 | 6 | -------------------------------------------------------------------------------- /ExChangeSVGColor/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QDomElement; 9 | class Widget : public QWidget 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | Widget(QWidget *parent = nullptr); 15 | ~Widget(); 16 | 17 | // QWidget interface 18 | protected: 19 | virtual void paintEvent(QPaintEvent *event) override; 20 | 21 | public slots: 22 | void onBtnChecked(bool checked); 23 | 24 | private: 25 | QToolButton* m_btn; 26 | QToolButton* m_btn2; 27 | const int m_width = 100; 28 | }; 29 | 30 | 31 | void SetAttrRecur(QDomElement &elem, QString strtagname, QString strattr, QString strattrval); 32 | #endif // WIDGET_H 33 | -------------------------------------------------------------------------------- /ExIntelDete/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | Widget::Widget(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | } 7 | 8 | Widget::~Widget() 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /ExIntelDete/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = nullptr); 12 | ~Widget(); 13 | }; 14 | #endif // WIDGET_H 15 | -------------------------------------------------------------------------------- /ExPicShot/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /ExPicShot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(ExPicShot VERSION 0.1 LANGUAGES CXX) 4 | 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | set(CMAKE_AUTOUIC ON) 8 | set(CMAKE_AUTOMOC ON) 9 | set(CMAKE_AUTORCC ON) 10 | 11 | set(CMAKE_CXX_STANDARD 17) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) 15 | find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) 16 | 17 | include_directories(3rdparty/spdlog/include) # spdlog 路径,不必再添加链接库 18 | 19 | set(PROJECT_SOURCES 20 | main.cpp 21 | widget.cpp 22 | widget.h 23 | ) 24 | 25 | add_executable(ExPicShot 26 | ${PROJECT_SOURCES} 27 | ) 28 | 29 | target_link_libraries(ExPicShot PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) 30 | 31 | set_target_properties(ExPicShot PROPERTIES 32 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 33 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 34 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 35 | ) 36 | 37 | -------------------------------------------------------------------------------- /ExPicShot/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | Widget::Widget(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | } 7 | 8 | Widget::~Widget() 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /ExPicShot/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = nullptr); 12 | ~Widget(); 13 | }; 14 | #endif // WIDGET_H 15 | -------------------------------------------------------------------------------- /ExThreadSafety/multithread.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * Copyright (C) 2022 偕臧 All rights reserved. 3 | * 4 | * Author: 偕臧 5 | * GitHub: https://github.com/xmuli 6 | * Blog: https://ifmet.cn 7 | * 8 | * Create: 2022.01.12 9 | * Modify: 2022.01.14 10 | * File: multithread.h 11 | * Description: 一个多线程竞争的例子,分析出现的“非线程安全”的具体原因,以及两个 12 | * 解决方法:atomic 和 mutex 13 | * 14 | ******************************************************************/ 15 | #ifndef MULTITHREAD_H 16 | #define MULTITHREAD_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | using namespace std; 23 | 24 | // 方案一:定义为原子变量 atomic 25 | //atomic g_num = 0; 26 | 27 | // 方案二:加锁 mutex 28 | int g_num = 0; 29 | mutex g_mutex; 30 | 31 | void addition() 32 | { 33 | for (int i = 0; i < 5000; ++i) { 34 | g_mutex.lock(); // 尝试和下一行的 cout 行互换位置 35 | cout << "threadId:" << this_thread::get_id() << " g_num:" << g_num << endl; 36 | g_num++; 37 | g_mutex.unlock(); 38 | } 39 | } 40 | 41 | 使用示例 42 | int main() 43 | { 44 | thread th1(addition); 45 | thread th2(addition); 46 | th1.join(); 47 | th2.join(); 48 | 49 | cout << "g_num:" << g_num << endl; 50 | return 0; 51 | } 52 | 53 | #endif -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/arrow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/copy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/download.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/ellipse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/exit.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-ellipse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-rect.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/line.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/mosaic.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/pen.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/recover.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/rectangle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/revoke.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/screenshot.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/text.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/update.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/cancel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 取消 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/ellipse.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 圆形 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/finish.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 确定 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/mosaic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 马赛克 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pen.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 画笔 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/rectangle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 矩形 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/renewal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 恢复 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/revocation.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 撤回 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 保存 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/serialnumber.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 标注 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 文字 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/main.cpp: -------------------------------------------------------------------------------- 1 | #include "testbtstyle.h" 2 | #include "widget.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); 12 | QApplication a(argc, argv); 13 | // Widget w; 14 | // w.show(); 15 | 16 | QStringList listStyle = QStyleFactory::keys(); 17 | foreach(QString val, listStyle) 18 | qDebug()<setWindowTitle("MacOS 12.6 + Qt 5.15.2 + Style: Windows"); 23 | t->show(); 24 | 25 | return a.exec(); 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTBTSTYLE_H 2 | #define TESTBTSTYLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class TestBTStyle : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | TestBTStyle(QWidget *parent = nullptr); 14 | 15 | protected: 16 | void paintEvent(QPaintEvent *event) override; 17 | 18 | private: 19 | QVector m_vItem; 20 | std::vector> m_vTbName; 21 | }; 22 | 23 | #endif // TESTBTSTYLE_H 24 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | Widget::Widget(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | } 7 | 8 | Widget::~Widget() 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = nullptr); 12 | ~Widget(); 13 | }; 14 | #endif // WIDGET_H 15 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/QMakeAutoRaise.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++17 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | widget.cpp \ 14 | testbtstyle.cpp 15 | 16 | HEADERS += \ 17 | widget.h \ 18 | testbtstyle.h 19 | 20 | RESOURCES += resources.qrc \ 21 | resources.qrc 22 | 23 | # Default rules for deployment. 24 | qnx: target.path = /tmp/$${TARGET}/bin 25 | else: unix:!android: target.path = /opt/$${TARGET}/bin 26 | !isEmpty(target.path): INSTALLS += target 27 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/arrow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/copy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/download.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/ellipse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/exit.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-ellipse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-rect.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/line.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/mosaic.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/pen.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/recover.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/rectangle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/revoke.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/right.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/screenshot.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/text.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/update.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/cancel.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 取消 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/ellipse.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 圆形 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/finish.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 确定 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/mosaic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 马赛克 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pen.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 画笔 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/rectangle.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 矩形 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/renewal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 恢复 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/revocation.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 撤回 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 保存 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/serialnumber.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 标注 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 文字 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/main.cpp: -------------------------------------------------------------------------------- 1 | #include "testbtstyle.h" 2 | #include "widget.h" 3 | 4 | #include 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | // Widget w; 10 | // w.show(); 11 | 12 | auto t = new TestBTStyle(); 13 | t->show(); 14 | 15 | return a.exec(); 16 | } 17 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTBTSTYLE_H 2 | #define TESTBTSTYLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class TestBTStyle : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | TestBTStyle(QWidget *parent = nullptr); 14 | 15 | protected: 16 | void paintEvent(QPaintEvent *event) override; 17 | 18 | private: 19 | QVector m_vItem; 20 | std::vector> m_vTbName; 21 | }; 22 | 23 | #endif // TESTBTSTYLE_H 24 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | 3 | Widget::Widget(QWidget *parent) 4 | : QWidget(parent) 5 | { 6 | } 7 | 8 | Widget::~Widget() 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = nullptr); 12 | ~Widget(); 13 | }; 14 | #endif // WIDGET_H 15 | -------------------------------------------------------------------------------- /QtComboModeShow/QtComboModeShow.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | -------------------------------------------------------------------------------- /QtComboModeShow/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | class A 7 | { 8 | public: 9 | 10 | void add(A *pt){ m_v.push_back(pt); } 11 | 12 | QVector m_v; 13 | QString m_name; 14 | }; 15 | 16 | class B : public A 17 | { 18 | public: 19 | void add(A *pt){ m_v.push_back(pt); } 20 | }; 21 | 22 | 23 | class C : public A 24 | { 25 | public: 26 | }; 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | A ma1; 31 | B mb1, mb2, mb3, mb4; 32 | C mc1, mc2, mc3; 33 | 34 | ma1.add(&mb1); ma1.add(&mb3); 35 | mb1.add(&mc1); mb1.add(&mb2); 36 | mb3.add(&mc2); mb3.add(&mc3); mb3.add(&mb4); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /QtConnect/QtConnect.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | widget.cpp 14 | 15 | HEADERS += \ 16 | widget.h 17 | 18 | # Default rules for deployment. 19 | qnx: target.path = /tmp/$${TARGET}/bin 20 | else: unix:!android: target.path = /opt/$${TARGET}/bin 21 | !isEmpty(target.path): INSTALLS += target 22 | -------------------------------------------------------------------------------- /QtConnect/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 | -------------------------------------------------------------------------------- /QtConnect/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = nullptr); 12 | ~Widget(); 13 | }; 14 | #endif // WIDGET_H 15 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExCustomMainWin.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCUSTOMMAINWIN_H 2 | #define EXCUSTOMMAINWIN_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "ExDlgSize.h" 9 | #include "ExDlgSetHeaders.h" 10 | #include "ExDlgLocate.h" 11 | #include 12 | 13 | namespace Ui { 14 | class ExCustomMainWin; 15 | } 16 | 17 | class ExCustomMainWin : public QMainWindow 18 | { 19 | Q_OBJECT 20 | 21 | public: 22 | explicit ExCustomMainWin(QWidget *parent = nullptr); 23 | ~ExCustomMainWin(); 24 | 25 | void setACellText(int row, int col, QString text); //定位到单元格,并设置字符串 26 | void setActLocateEnable(bool enable); //设置actLocatee的enabled属性 27 | void setDlgLocateNull(); //将ExDlgLocate指针设置为NULL 28 | 29 | private slots: 30 | void on_actSetHeader_triggered(); 31 | void on_actSetSize_triggered(); 32 | void on_actLocate_triggered(); 33 | void on_currentChanged(const QModelIndex ¤t, const QModelIndex &previous); 34 | 35 | private: 36 | Ui::ExCustomMainWin *ui; 37 | 38 | QStandardItemModel *m_model; //数据模型 39 | QItemSelectionModel *m_seleModel; //item选择模型 40 | ExDlgSetHeaders *m_dlgSetHeaders; 41 | ExDlgLocate *m_dlglocate; 42 | QLabel *m_labCellPos; //当前单元格行列号 43 | QLabel *m_labCellText; //当前单元格内容 44 | }; 45 | 46 | #endif // EXCUSTOMMAINWIN_H 47 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExDlgLocate.h: -------------------------------------------------------------------------------- 1 | #ifndef EXDLGLOCATE_H 2 | #define EXDLGLOCATE_H 3 | 4 | #include 5 | 6 | class ExCustomMainWin; 7 | 8 | 9 | namespace Ui { 10 | class ExDlgLocate; 11 | } 12 | 13 | class ExDlgLocate : public QDialog 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit ExDlgLocate(QWidget *parent = nullptr); 19 | ~ExDlgLocate(); 20 | 21 | void setSpinRange(int rowCount, int colCount); //设置spin的设定(最大)值 22 | void setSpinValue(int rowNo, int colNo); //设置spin的初始值 23 | 24 | private slots: 25 | void on_btnSetText_clicked(); 26 | void on_btnClose_clicked(); 27 | 28 | private: 29 | Ui::ExDlgLocate *ui; 30 | 31 | // QWidget interface 32 | protected: 33 | virtual void closeEvent(QCloseEvent *event) override; //窗口关闭事件,关闭时释放本窗口 34 | virtual void showEvent(QShowEvent *event) override; //窗口显示事件 35 | }; 36 | 37 | #endif // EXDLGLOCATE_H 38 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExDlgSetHeaders.cpp: -------------------------------------------------------------------------------- 1 | #include "ExDlgSetHeaders.h" 2 | #include "ui_ExDlgSetHeaders.h" 3 | #include 4 | 5 | ExDlgSetHeaders::ExDlgSetHeaders(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::ExDlgSetHeaders) 8 | { 9 | ui->setupUi(this); 10 | m_model = new QStringListModel(this); 11 | ui->listView->setModel(m_model); 12 | } 13 | 14 | ExDlgSetHeaders::~ExDlgSetHeaders() 15 | { 16 | QMessageBox::information(this,"提示","设置表头消息框被删除"); 17 | delete ui; 18 | } 19 | 20 | void ExDlgSetHeaders::setHeaderList(QStringList &headers) 21 | { 22 | m_model->setStringList(headers); //初始化字符串列表 23 | } 24 | 25 | QStringList ExDlgSetHeaders::headerList() 26 | { 27 | return m_model->stringList(); //返回字符串列表 28 | } 29 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExDlgSetHeaders.h: -------------------------------------------------------------------------------- 1 | #ifndef EXDLGSETHEADERS_H 2 | #define EXDLGSETHEADERS_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class ExDlgSetHeaders; 9 | } 10 | 11 | class ExDlgSetHeaders : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit ExDlgSetHeaders(QWidget *parent = nullptr); 17 | ~ExDlgSetHeaders(); 18 | 19 | void setHeaderList(QStringList& headers); 20 | QStringList headerList(); 21 | 22 | private: 23 | Ui::ExDlgSetHeaders *ui; 24 | 25 | QStringListModel *m_model; //管理字符串列表数据 26 | }; 27 | 28 | #endif // EXDLGSETHEADERS_H 29 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExDlgSize.cpp: -------------------------------------------------------------------------------- 1 | #include "ExDlgSize.h" 2 | #include "ui_ExDlgSize.h" 3 | #include 4 | 5 | ExDlgSize::ExDlgSize(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::ExDlgSize) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | ExDlgSize::~ExDlgSize() 13 | { 14 | QMessageBox::information(this,"提示","设置表格行列数对话框被删除"); 15 | delete ui; 16 | } 17 | 18 | int ExDlgSize::getRowCount() 19 | { 20 | return ui->spinBoxRow->value(); 21 | } 22 | 23 | int ExDlgSize::getColCount() 24 | { 25 | return ui->spinBoxCol->value(); 26 | } 27 | 28 | void ExDlgSize::setRowCol(int row, int col) 29 | { 30 | ui->spinBoxRow->setValue(row); 31 | ui->spinBoxCol->setValue(col); 32 | } 33 | -------------------------------------------------------------------------------- /QtCustomDialogEx/ExDlgSize.h: -------------------------------------------------------------------------------- 1 | #ifndef EXDLGSIZE_H 2 | #define EXDLGSIZE_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExDlgSize; 8 | } 9 | 10 | class ExDlgSize : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExDlgSize(QWidget *parent = nullptr); 16 | ~ExDlgSize(); 17 | 18 | int getRowCount(); 19 | int getColCount(); 20 | void setRowCol(int row, int col); 21 | 22 | private: 23 | Ui::ExDlgSize *ui; 24 | }; 25 | 26 | #endif // EXDLGSIZE_H 27 | -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image001.png -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image002.png -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image003.png -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image004.jpg -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image005.png -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image006.png -------------------------------------------------------------------------------- /QtCustomDialogEx/images/Image007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/images/Image007.png -------------------------------------------------------------------------------- /QtCustomDialogEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExCustomMainWin.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExCustomMainWin w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtCustomDialogEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtCustomDialogEx/qt.ico -------------------------------------------------------------------------------- /QtCustomDialogEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image001.png 4 | images/Image002.png 5 | images/Image003.png 6 | images/Image004.jpg 7 | images/Image005.png 8 | images/Image006.png 9 | images/Image007.png 10 | 11 | 12 | -------------------------------------------------------------------------------- /QtCustomTypeAndQMetaType/QtCustomTypeAndQMetaType.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | -------------------------------------------------------------------------------- /QtCustomTypeAndQMetaType/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class A{public: int i;}; 6 | class B{public:int i;}; 7 | class D{public:D(int){}};//该类无 public 默认构造函数 8 | class E{}; 9 | //class F{private: ~F(){};}; 写露了 10 | //声明类型 11 | Q_DECLARE_METATYPE(A) 12 | Q_DECLARE_METATYPE(B) 13 | //Q_DECLARE_METATYPE(D) //错误,类 D 没有公有的默认构造函数 14 | 15 | int main(int argc, char *argv[]){ 16 | //注册类型 17 | qRegisterMetaType(); 18 | //qRegisterMetaType(); //错误,类型 E 未使用宏 Q_DECLARE_METATYPE(T)声明 19 | A ma; ma.i=1; 20 | B mb; mb.i=2; 21 | //QVariant v1(ma); //错误,没有相应的构造函数。 22 | QVariant v; 23 | v.setValue(ma); //将对象 ma 存储在 v 之中 24 | cout<().i<(); //把存储在 v 之中的对象 ma 赋值给 ma1 34 | cout<(); //错误,类型不相同。 37 | mb1=v.value(); //正确,由类型 A 转换到类型 B 失败,此时 value 会返回一个默认构造的值。 38 | cout< 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class ExDateTime; 10 | } 11 | 12 | class ExDateTime : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit ExDateTime(QWidget *parent = nullptr); 18 | ~ExDateTime(); 19 | 20 | private slots: 21 | void on_btnGetDateTime_clicked(); 22 | void on_btnStatrt_clicked(); 23 | void on_btnStop_clicked(); 24 | void onTimerOut(); //处理计时器的信号的槽函数 25 | 26 | void on_calendarWidget_selectionChanged(); 27 | 28 | void on_btnPeriod_clicked(); 29 | 30 | private: 31 | Ui::ExDateTime *ui; 32 | 33 | QTimer* m_timer; //定时器(不可见控件) 34 | QTime m_time; //计时器(此处用作) 35 | 36 | 37 | 38 | }; 39 | 40 | #endif // EXDATETIME_H 41 | -------------------------------------------------------------------------------- /QtDateTimeEx/QtDateTimeEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-24T15:33:12 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtDateTimeEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExDateTime.cpp 30 | 31 | HEADERS += \ 32 | ExDateTime.h 33 | 34 | FORMS += \ 35 | ExDateTime.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtDateTimeEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExDateTime.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExDateTime w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtDateTimeEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtDateTimeEx/qt.ico -------------------------------------------------------------------------------- /QtEvent/QtEvent.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | QT += widgets 3 | 4 | CONFIG += c++11 console 5 | CONFIG -= app_bundle 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp 13 | 14 | # Default rules for deployment. 15 | qnx: target.path = /tmp/$${TARGET}/bin 16 | else: unix:!android: target.path = /opt/$${TARGET}/bin 17 | !isEmpty(target.path): INSTALLS += target 18 | -------------------------------------------------------------------------------- /QtHttpEx/ExHttp.h: -------------------------------------------------------------------------------- 1 | #ifndef EXHTTP_H 2 | #define EXHTTP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace Ui { 12 | class ExHttp; 13 | } 14 | 15 | class ExHttp : public QMainWindow 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit ExHttp(QWidget *parent = nullptr); 21 | ~ExHttp(); 22 | 23 | private slots: 24 | void on_btnDown_clicked(); //下载文件 25 | void on_btnFile_clicked(); //默认的保存路径 26 | void on_lineEditUrl_textChanged(const QString &arg1); 27 | 28 | void onFinished(); //网络响应结束 29 | void onReadyRead(); //读取下载的数据 30 | void onDownloadProgress(qint64 bytesRea, qint64 totalBytes); //下载进程 31 | 32 | private: 33 | Ui::ExHttp *ui; 34 | 35 | QNetworkAccessManager* m_networkManager; //网络管理 36 | QNetworkReply* m_reply; //网络响应 37 | QFile* m_file; //下载保存的临时文件 38 | }; 39 | 40 | #endif // EXHTTP_H 41 | -------------------------------------------------------------------------------- /QtHttpEx/images/Image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image1.png -------------------------------------------------------------------------------- /QtHttpEx/images/Image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image2.jpg -------------------------------------------------------------------------------- /QtHttpEx/images/Image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image3.png -------------------------------------------------------------------------------- /QtHttpEx/images/Image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image4.png -------------------------------------------------------------------------------- /QtHttpEx/images/Image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image5.png -------------------------------------------------------------------------------- /QtHttpEx/images/Image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/Image6.png -------------------------------------------------------------------------------- /QtHttpEx/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/icon.icns -------------------------------------------------------------------------------- /QtHttpEx/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtHttpEx/images/icon.ico -------------------------------------------------------------------------------- /QtHttpEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExHttp.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExHttp w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtHttpEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image6.png 4 | images/Image3.png 5 | 6 | 7 | -------------------------------------------------------------------------------- /QtMDIEx/ExMDI.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExMDI 4 | 5 | 6 | 7 | 0 8 | 0 9 | 933 10 | 552 11 | 12 | 13 | 14 | ExMDI 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /QtMDIEx/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/.DS_Store -------------------------------------------------------------------------------- /QtMDIEx/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/1.png -------------------------------------------------------------------------------- /QtMDIEx/images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/10.png -------------------------------------------------------------------------------- /QtMDIEx/images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/11.png -------------------------------------------------------------------------------- /QtMDIEx/images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/12.png -------------------------------------------------------------------------------- /QtMDIEx/images/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/13.jpg -------------------------------------------------------------------------------- /QtMDIEx/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/2.png -------------------------------------------------------------------------------- /QtMDIEx/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/3.png -------------------------------------------------------------------------------- /QtMDIEx/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/4.png -------------------------------------------------------------------------------- /QtMDIEx/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/5.png -------------------------------------------------------------------------------- /QtMDIEx/images/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/6.jpg -------------------------------------------------------------------------------- /QtMDIEx/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/7.png -------------------------------------------------------------------------------- /QtMDIEx/images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/8.png -------------------------------------------------------------------------------- /QtMDIEx/images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMDIEx/images/9.png -------------------------------------------------------------------------------- /QtMDIEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExMDI.h" 2 | #include "ExMainWindow.h" 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QApplication a(argc, argv); 8 | ExMainWindow w; 9 | w.show(); 10 | 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /QtMDIEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/1.png 4 | images/2.png 5 | images/3.png 6 | images/4.png 7 | images/5.png 8 | images/6.jpg 9 | images/7.png 10 | images/8.png 11 | images/9.png 12 | images/10.png 13 | images/11.png 14 | images/12.png 15 | images/13.jpg 16 | 17 | 18 | -------------------------------------------------------------------------------- /QtMeatObjectEx/ExPerson.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 xmulitech@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "ExPerson.h" 17 | 18 | //加一个参后的构造函数 19 | ExPerson::ExPerson(QString name, QObject *parent) : QObject(parent) 20 | { 21 | m_name = name; 22 | } 23 | 24 | int ExPerson::getAge() 25 | { 26 | return m_age; 27 | } 28 | 29 | void ExPerson::setAge(int value) 30 | { 31 | m_age = value; 32 | emit ageChanged(m_age); //发射信号 33 | } 34 | 35 | void ExPerson::incAge() 36 | { 37 | m_age++; 38 | emit ageChanged(m_age); //发射信号 39 | } 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /QtMeatObjectEx/ExWidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 xmulitech@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef EXWIDGET_H 17 | #define EXWIDGET_H 18 | 19 | #include 20 | #include "ExPerson.h" 21 | 22 | namespace Ui { 23 | class ExWidget; 24 | } 25 | 26 | class ExWidget : public QWidget 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | explicit ExWidget(QWidget *parent = nullptr); 32 | ~ExWidget(); 33 | 34 | private slots: 35 | void onAgeChange(int val); //自定义的槽函数 36 | void onSpinValChange(int val); 37 | 38 | void onBtnClear(); //UI界面的槽函数 39 | void onBtnBoyInc(); 40 | void onBtnGrilInc(); 41 | void onClassInfo(); 42 | 43 | private: 44 | Ui::ExWidget *ui; 45 | 46 | ExPerson* m_boy; 47 | ExPerson* m_girl; 48 | }; 49 | 50 | #endif // EXWIDGET_H 51 | -------------------------------------------------------------------------------- /QtMeatObjectEx/QtMeatObjectEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-16T20:47:42 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtMeatObjectEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExWidget.cpp \ 30 | ExPerson.cpp 31 | 32 | HEADERS += \ 33 | ExWidget.h \ 34 | ExPerson.h 35 | 36 | FORMS += \ 37 | ExWidget.ui 38 | 39 | RC_ICONS += qt.ico 40 | 41 | 42 | # Default rules for deployment. 43 | qnx: target.path = /tmp/$${TARGET}/bin 44 | else: unix:!android: target.path = /opt/$${TARGET}/bin 45 | !isEmpty(target.path): INSTALLS += target 46 | -------------------------------------------------------------------------------- /QtMeatObjectEx/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 xmulitech@gmail.com 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "ExWidget.h" 17 | #include 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | QApplication a(argc, argv); 22 | ExWidget w; 23 | w.show(); 24 | 25 | return a.exec(); 26 | } 27 | -------------------------------------------------------------------------------- /QtMeatObjectEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtMeatObjectEx/qt.ico -------------------------------------------------------------------------------- /QtMetaAboutClass/QtMetaAboutClass.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | 18 | HEADERS += \ 19 | m.h 20 | 21 | -------------------------------------------------------------------------------- /QtMetaAboutClass/m.h: -------------------------------------------------------------------------------- 1 | #ifndef M_H 2 | #define M_H 3 | 4 | #include 5 | class A:public QObject{ Q_OBJECT}; 6 | class B:public A{ Q_OBJECT}; 7 | class C:public QObject{Q_OBJECT}; 8 | class D:public C{}; 9 | 10 | #endif // M_H 11 | -------------------------------------------------------------------------------- /QtMyStyleEx/.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | *~ 5 | *.autosave 6 | *.a 7 | *.core 8 | *.moc 9 | *.o 10 | *.obj 11 | *.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | .directory 25 | *.debug 26 | Makefile* 27 | *.prl 28 | *.app 29 | moc_*.cpp 30 | ui_*.h 31 | qrc_*.cpp 32 | Thumbs.db 33 | *.res 34 | *.rc 35 | /.qmake.cache 36 | /.qmake.stash 37 | 38 | # qtcreator generated files 39 | *.pro.user* 40 | 41 | # xemacs temporary files 42 | *.flc 43 | 44 | # Vim temporary files 45 | .*.swp 46 | 47 | # Visual Studio generated files 48 | *.ib_pdb_index 49 | *.idb 50 | *.ilk 51 | *.pdb 52 | *.sln 53 | *.suo 54 | *.vcproj 55 | *vcproj.*.*.user 56 | *.ncb 57 | *.sdf 58 | *.opensdf 59 | *.vcxproj 60 | *vcxproj.* 61 | 62 | # MinGW generated files 63 | *.Debug 64 | *.Release 65 | 66 | # Python byte code 67 | *.pyc 68 | 69 | # Binaries 70 | # -------- 71 | *.dll 72 | *.exe 73 | 74 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample01/QtStyleEx/QtStyleEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2020-02-13T22:45:19 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtStyleEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | widget.cpp 30 | 31 | HEADERS += \ 32 | widget.h 33 | 34 | # Default rules for deployment. 35 | qnx: target.path = /tmp/$${TARGET}/bin 36 | else: unix:!android: target.path = /opt/$${TARGET}/bin 37 | !isEmpty(target.path): INSTALLS += target 38 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample01/QtStyleEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample01/QtStyleEx/widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | 6 | class Widget : public QWidget 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | Widget(QWidget *parent = 0); 12 | ~Widget(); 13 | 14 | void init(); 15 | }; 16 | 17 | #endif // WIDGET_H 18 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample02/QtStyleEx/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Gmail: touwoyimuli@gmai.com 4 | * blogs: https://blog.csdn.net/qq_33154343 5 | * 6 | * ------------------------------------------------- 7 | * Copyright 2019~2020 touwoyimuli 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include "widget.h" 23 | #include 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | QApplication a(argc, argv); 28 | Widget w; 29 | w.show(); 30 | 31 | return a.exec(); 32 | } 33 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample02/QtStyleEx/mystyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Gmail: touwoyimuli@gmai.com 4 | * blogs: https://blog.csdn.net/qq_33154343 5 | * 6 | * ------------------------------------------------- 7 | * Copyright 2019~2020 touwoyimuli 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef MYSTYLE_H 23 | #define MYSTYLE_H 24 | 25 | #include 26 | 27 | class MyStyle : public QCommonStyle 28 | { 29 | public: 30 | MyStyle(); 31 | 32 | // QStyle interface 33 | public: 34 | virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w) const override; 35 | }; 36 | 37 | #endif // MYSTYLE_H 38 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample02/QtStyleEx/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Gmail: touwoyimuli@gmai.com 4 | * blogs: https://blog.csdn.net/qq_33154343 5 | * 6 | * ------------------------------------------------- 7 | * Copyright 2019~2020 touwoyimuli 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef WIDGET_H 23 | #define WIDGET_H 24 | 25 | #include 26 | 27 | class Widget : public QWidget 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | Widget(QWidget *parent = 0); 33 | ~Widget(); 34 | 35 | void init(); 36 | }; 37 | 38 | #endif // WIDGET_H 39 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample03/QtStyleEx/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Gmail: touwoyimuli@gmai.com 4 | * blogs: https://blog.csdn.net/qq_33154343 5 | * 6 | * ------------------------------------------------- 7 | * Copyright 2019~2020 touwoyimuli 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #include "widget.h" 23 | #include 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | QApplication a(argc, argv); 28 | Widget w; 29 | w.show(); 30 | 31 | return a.exec(); 32 | } 33 | -------------------------------------------------------------------------------- /QtMyStyleEx/QtExample03/QtStyleEx/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Gmail: touwoyimuli@gmai.com 4 | * blogs: https://blog.csdn.net/qq_33154343 5 | * 6 | * ------------------------------------------------- 7 | * Copyright 2019~2020 touwoyimuli 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | */ 21 | 22 | #ifndef WIDGET_H 23 | #define WIDGET_H 24 | 25 | #include 26 | 27 | class Widget : public QWidget 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | Widget(QWidget *parent = 0); 33 | ~Widget(); 34 | 35 | void init(); 36 | }; 37 | 38 | #endif // WIDGET_H 39 | -------------------------------------------------------------------------------- /QtObjectTree/QtObjectTree.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | widget.cpp 14 | 15 | HEADERS += \ 16 | widget.h 17 | 18 | # Default rules for deployment. 19 | qnx: target.path = /tmp/$${TARGET}/bin 20 | else: unix:!android: target.path = /opt/$${TARGET}/bin 21 | !isEmpty(target.path): INSTALLS += target 22 | -------------------------------------------------------------------------------- /QtProperty/QtProperty.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | 18 | HEADERS += \ 19 | m.h 20 | -------------------------------------------------------------------------------- /QtProperty/m.h: -------------------------------------------------------------------------------- 1 | #ifndef M_H //要使用元对象系统,需在头文件中定义类。 2 | #define M_H 3 | 4 | #include 5 | 6 | class B{public:int i;}; 7 | class C{public:int i;}; 8 | class D{public:int i;}; 9 | Q_DECLARE_METATYPE(B) 10 | Q_DECLARE_METATYPE(C) 11 | //Q_DECLARE_METATYPE(D) 12 | 13 | class Z:public QObject{ Q_OBJECT 14 | public: Z(){} 15 | Q_PROPERTY(B b READ fb WRITE gb) 16 | Q_PROPERTY(C c READ fc WRITE gc) 17 | Q_PROPERTY(D d READ fd WRITE gd) 18 | B fb(){return m_mb;} void gb(B x){m_mb=x;} 19 | C fc(){return m_mc;} void gc(C x){m_mc=x;} 20 | D fd(){return m_md;} void gd(D x){m_md=x;} 21 | B m_mb; C m_mc; D m_md; 22 | }; 23 | 24 | #endif // M_H 25 | -------------------------------------------------------------------------------- /QtQDialogEx/ExDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EXDIALOG_H 2 | #define EXDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExDialog; 8 | } 9 | 10 | class ExDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExDialog(QWidget *parent = nullptr); 16 | ~ExDialog(); 17 | 18 | private slots: 19 | void on_btnOpenFile_clicked(); //打开一个文件 20 | void on_btnOpenFiles_clicked(); //打开多个文件 21 | void on_btnExistingDir_clicked(); //选择已有目录 22 | void on_btnGetColor_clicked(); //选择颜色 23 | void on_btnGetFont_clicked(); //选择字体 24 | void on_btnSaveFile_clicked(); //保存文件 25 | 26 | void on_btnQuestion_clicked(); 27 | void on_btnInformation_clicked(); 28 | void on_btnWarning_clicked(); 29 | void on_btnCritical_clicked(); 30 | void on_btnAbout_clicked(); 31 | void on_btnAboutQt_clicked(); 32 | 33 | void on_btnGetString_clicked(); //输入字符串 34 | void on_btnGetItem_clicked(); //item选择输入 35 | void on_btnInt_clicked(); //输入整数 36 | void on_btnDouble_clicked(); //输入浮点数 37 | 38 | private: 39 | Ui::ExDialog *ui; 40 | }; 41 | 42 | #endif // EXDIALOG_H 43 | -------------------------------------------------------------------------------- /QtQDialogEx/QtQDialogEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-10-01T15:57:01 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQDialogEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExDialog.cpp 30 | 31 | HEADERS += \ 32 | ExDialog.h 33 | 34 | FORMS += \ 35 | ExDialog.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQDialogEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExDialog.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExDialog w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQDialogEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQDialogEx/qt.ico -------------------------------------------------------------------------------- /QtQFileSystemModelEx/ExQFileSystemModel.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQFILESYSTEMMODEL_H 2 | #define EXQFILESYSTEMMODEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace Ui { 10 | class ExQFileSystemModel; 11 | } 12 | 13 | class ExQFileSystemModel : public QMainWindow 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit ExQFileSystemModel(QWidget *parent = nullptr); 19 | ~ExQFileSystemModel(); 20 | 21 | void init(); //初始化,以及初始化状态栏 22 | 23 | private slots: 24 | void on_treeView_clicked(const QModelIndex &index); //单击treeView,会在状态栏显示当前节点的信息 25 | 26 | private: 27 | Ui::ExQFileSystemModel *ui; 28 | 29 | QLabel* m_labFileName; //文件名 30 | QLabel* m_labFileSize; //文件大小 31 | QLabel* m_labFileType; //文件类型 32 | QLabel* m_labPath; //路径 33 | QCheckBox* m_chkBoxIsFile; //当前是否为文件或文件夹 34 | QFileSystemModel* m_model; //设置文件系统的模型 35 | }; 36 | 37 | #endif // EXQFILESYSTEMMODEL_H 38 | -------------------------------------------------------------------------------- /QtQFileSystemModelEx/QtQFileSystemModelEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-09-14T16:56:30 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQFileSystemModelEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQFileSystemModel.cpp 30 | 31 | HEADERS += \ 32 | ExQFileSystemModel.h 33 | 34 | FORMS += \ 35 | ExQFileSystemModel.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQFileSystemModelEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQFileSystemModel.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQFileSystemModel w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQFileSystemModelEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQFileSystemModelEx/qt.ico -------------------------------------------------------------------------------- /QtQHostInfoEx/ExQHostInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQHOSTINFO_H 2 | #define EXQHOSTINFO_H 3 | 4 | #include 5 | #include 6 | class QHostInfo; 7 | 8 | 9 | namespace Ui { 10 | class ExQHostInfo; 11 | } 12 | 13 | class ExQHostInfo : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit ExQHostInfo(QWidget *parent = nullptr); 19 | ~ExQHostInfo(); 20 | 21 | private: 22 | QString protocolName(QAbstractSocket::NetworkLayerProtocol protocol); //通过协议类型返回协议名称 23 | 24 | private slots: 25 | void on_btnGetHostInfo_clicked(); //QHostInfo查询主机名和IP 26 | void on_btnAllAddresses_clicked(); //QNetworkInterface::allAddresses() 27 | void on_btnAllInterfaces_clicked(); //QNetworkInterface::allInterfaces() 28 | void on_btnFindIP_clicked(); //QHostInfo查询左侧域名IP地址 29 | void on_btnClean_clicked(); //清空文本框信息 30 | 31 | void onLookedUpHostInfo(const QHostInfo& host); //查询主机信息的槽函数 32 | 33 | private: 34 | Ui::ExQHostInfo *ui; 35 | 36 | }; 37 | 38 | #endif // EXQHOSTINFO_H 39 | -------------------------------------------------------------------------------- /QtQHostInfoEx/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQHostInfoEx/Icon.icns -------------------------------------------------------------------------------- /QtQHostInfoEx/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQHostInfoEx/icon.ico -------------------------------------------------------------------------------- /QtQHostInfoEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQHostInfo.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQHostInfo w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQMetaProperty/QtQMetaProperty.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | 18 | HEADERS += \ 19 | m.h 20 | -------------------------------------------------------------------------------- /QtQMetaProperty/m.h: -------------------------------------------------------------------------------- 1 | #ifndef M_H //要使用元对象系统,需在头文件中定义类。 2 | #define M_H 3 | 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | class Z:public QObject{ 9 | Q_OBJECT 10 | public: 11 | Q_PROPERTY(int b READ gb WRITE sb) 12 | int gb(){return m_mb;} 13 | void sb(int x){m_mb=x;} 14 | int m_mb; 15 | }; 16 | #endif // M_H 17 | -------------------------------------------------------------------------------- /QtQMetaProperty/main.cpp: -------------------------------------------------------------------------------- 1 | // 使用反射机制获取属性的信息 2 | // 使用 QMetaObject 成员函数存取属性值 3 | 4 | #include "m.h" 5 | #include 6 | int main(int argc, char *argv[]) 7 | { 8 | Z mz; 9 | const QMetaObject *p = mz.metaObject(); 10 | QMetaProperty pe = p->property(p->indexOfProperty("b")); 11 | 12 | cout << pe.name()<< endl; 13 | cout << pe.typeName()<< endl; 14 | pe.write(&mz, 14); 15 | cout << pe.read(&mz).value()<setupUi(this); 9 | setWindowTitle(QObject::tr("QSlider、QScrollBar、QProgressBar控件的联动")); 10 | 11 | //ui->progressBarHor->setOrient1ation(Qt::Horizontal /*(the default) Qt::Vertical*/); 设置进度条水平或竖直 12 | 13 | connect(ui->sliderHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 14 | connect(ui->scrollBarHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 15 | connect(ui->scrollBarHor, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 16 | connect(ui->sliderVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 17 | connect(ui->scrollBarVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 18 | connect(ui->progressBarVer, SIGNAL(valueChanged(int)), this, SLOT(onValChange(int))); 19 | } 20 | 21 | ExQProgressBar::~ExQProgressBar() 22 | { 23 | delete ui; 24 | } 25 | 26 | //对应的槽函数 27 | void ExQProgressBar::onValChange(int val) 28 | { 29 | ui->sliderHor->setValue(val); 30 | ui->scrollBarHor->setValue(val); 31 | ui->progressBarHor->setValue(val); 32 | ui->sliderVer->setValue(val); 33 | ui->scrollBarVer->setValue(val); 34 | ui->progressBarVer->setValue(val); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /QtQProgressBarEx/ExQProgressBar.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQPROGRESSBAR_H 2 | #define EXQPROGRESSBAR_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQProgressBar; 8 | } 9 | 10 | class ExQProgressBar : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQProgressBar(QWidget *parent = nullptr); 16 | ~ExQProgressBar(); 17 | 18 | public slots: 19 | void onValChange(int val); 20 | 21 | private: 22 | Ui::ExQProgressBar *ui; 23 | }; 24 | 25 | #endif // EXQPROGRESSBAR_H 26 | -------------------------------------------------------------------------------- /QtQProgressBarEx/QtQProgressBarEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-24T14:55:33 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQProgressBarEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQProgressBar.cpp 30 | 31 | HEADERS += \ 32 | ExQProgressBar.h 33 | 34 | FORMS += \ 35 | ExQProgressBaressBarressbar.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQProgressBarEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQProgressBar.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQProgressBar w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQProgressBarEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQProgressBarEx/qt.ico -------------------------------------------------------------------------------- /QtQSliderEx/ExQSlider.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQSLIDER_H 2 | #define EXQSLIDER_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQSlider; 8 | } 9 | 10 | class ExQSlider : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQSlider(QWidget *parent = nullptr); 16 | ~ExQSlider(); 17 | 18 | public slots: 19 | void onSetClolor(int val); 20 | 21 | private: 22 | Ui::ExQSlider *ui; 23 | }; 24 | 25 | #endif // EXQSLIDER_H 26 | -------------------------------------------------------------------------------- /QtQSliderEx/QtQSliderEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-20T23:59:16 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQSliderEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQSlider.cpp 30 | 31 | HEADERS += \ 32 | ExQSlider.h 33 | 34 | FORMS += \ 35 | ExQSlider.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQSliderEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQSlider.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQSlider w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQSliderEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQSliderEx/qt.ico -------------------------------------------------------------------------------- /QtQStandardItemModelEx/ExDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef EXDELEGATE_H 2 | #define EXDELEGATE_H 3 | 4 | #include 5 | 6 | 7 | class ExDelegate : public QStyledItemDelegate 8 | { 9 | public: 10 | ExDelegate(); 11 | 12 | public: 13 | //若是写代理的组件,那么必须要有下面这是个重写这四个函数 14 | virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; //创建用于编辑的模型数据的widget组件,如一个QComboBox组件 15 | virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override; //从数据模型获取数据,显示在代理组件editor之中,让其编辑 16 | virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; //代理组件editor上的数据更新到数据模型 17 | virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; //用于给widget组件设置一个合适的大小 18 | }; 19 | 20 | #endif // EXDELEGATE_H 21 | -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image001.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image002.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image003.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image004.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image005.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image006.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image007.jpg -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image008.jpg -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image009.jpg -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image010.jpg -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image011.jpg -------------------------------------------------------------------------------- /QtQStandardItemModelEx/images/Image012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/images/Image012.png -------------------------------------------------------------------------------- /QtQStandardItemModelEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQStandardItemModel.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQStandardItemModel w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQStandardItemModelEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/qt.ico -------------------------------------------------------------------------------- /QtQStandardItemModelEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image001.png 4 | images/Image002.png 5 | images/Image003.png 6 | images/Image004.png 7 | images/Image005.png 8 | images/Image006.png 9 | images/Image007.jpg 10 | images/Image008.jpg 11 | images/Image009.jpg 12 | images/Image010.jpg 13 | images/Image011.jpg 14 | images/Image012.png 15 | 16 | 17 | -------------------------------------------------------------------------------- /QtQStandardItemModelEx/录入的人员信息.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStandardItemModelEx/录入的人员信息.txt -------------------------------------------------------------------------------- /QtQStringEx/ExQString.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQSTRING_H 2 | #define EXQSTRING_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQString; 8 | } 9 | 10 | class ExQString : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQString(QWidget *parent = nullptr); 16 | ~ExQString(); 17 | 18 | private slots: 19 | void on_btnResult_clicked(); 20 | void on_btn2_clicked(); 21 | void on_btn8_clicked(); 22 | void on_btn10_clicked(); 23 | void on_btn16_clicked(); 24 | 25 | private: 26 | Ui::ExQString *ui; 27 | 28 | float m_val; 29 | }; 30 | 31 | #endif // EXQSTRING_H 32 | -------------------------------------------------------------------------------- /QtQStringEx/QtQStringEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-18T12:06:43 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQStringEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQString.cpp 30 | 31 | HEADERS += \ 32 | ExQString.h 33 | 34 | FORMS += \ 35 | ExQString.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | 44 | RESOURCES += 45 | -------------------------------------------------------------------------------- /QtQStringEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQString.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQString w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQStringEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStringEx/qt.ico -------------------------------------------------------------------------------- /QtQStringFunEx/ExQStringFun.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQSTRINGFUN_H 2 | #define EXQSTRINGFUN_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQStringFun; 8 | } 9 | 10 | class ExQStringFun : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQStringFun(QWidget *parent = nullptr); 16 | ~ExQStringFun(); 17 | 18 | private slots: 19 | void on_btnAppend_clicked(); 20 | 21 | void on_btnPrepend_clicked(); 22 | 23 | void on_btnToUpper_clicked(); 24 | 25 | void on_btnToLower_clicked(); 26 | 27 | void on_btnLeft_clicked(); 28 | 29 | void on_btnRight_clicked(); 30 | 31 | void on_btnSection_clicked(); 32 | 33 | void on_btnSimplified_clicked(); 34 | 35 | void on_btnTrimmed_clicked(); 36 | 37 | void on_btnCount_clicked(); 38 | 39 | void on_btnSize_clicked(); 40 | 41 | void on_btnIndexOf_clicked(); 42 | 43 | 44 | void on_btnLastIndexOf_clicked(); 45 | 46 | void on_btnStartsWith_clicked(); 47 | 48 | void on_btnEndsWith_clicked(); 49 | 50 | void on_btnContains_clicked(); 51 | 52 | void on_btnIsNull_clicked(); 53 | 54 | void on_btnIsEmpty_clicked(); 55 | 56 | private: 57 | Ui::ExQStringFun *ui; 58 | }; 59 | 60 | #endif // EXQSTRINGFUN_H 61 | -------------------------------------------------------------------------------- /QtQStringFunEx/QtQStringFunEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-18T14:08:16 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQStringFunEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQStringFun.cpp 30 | 31 | HEADERS += \ 32 | ExQStringFun.h 33 | 34 | FORMS += \ 35 | ExQStringFun.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQStringFunEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQStringFun.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQStringFun w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQStringFunEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQStringFunEx/qt.ico -------------------------------------------------------------------------------- /QtQStringListModelEx/ExQStringListModel.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQStringListModel.h" 2 | #include "ui_ExQStringListModel.h" 3 | 4 | ExQStringListModel::ExQStringListModel(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::ExQStringListModel) 7 | { 8 | ui->setupUi(this); 9 | } 10 | 11 | ExQStringListModel::~ExQStringListModel() 12 | { 13 | delete ui; 14 | } 15 | -------------------------------------------------------------------------------- /QtQStringListModelEx/ExQStringListModel.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQSTRINGLISTMODEL_H 2 | #define EXQSTRINGLISTMODEL_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQStringListModel; 8 | } 9 | 10 | class ExQStringListModel : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQStringListModel(QWidget *parent = nullptr); 16 | ~ExQStringListModel(); 17 | 18 | private: 19 | Ui::ExQStringListModel *ui; 20 | }; 21 | 22 | #endif // EXQSTRINGLISTMODEL_H 23 | -------------------------------------------------------------------------------- /QtQStringListModelEx/ExQStringListModel.ui: -------------------------------------------------------------------------------- 1 | 2 | ExQStringListModel 3 | 4 | 5 | 6 | 0 7 | 0 8 | 400 9 | 300 10 | 11 | 12 | 13 | ExQStringListModel 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /QtQStringListModelEx/QtQStringListModelEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-09-14T21:36:41 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQStringListModelEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQStringListModel.cpp 30 | 31 | HEADERS += \ 32 | ExQStringListModel.h 33 | 34 | FORMS += \ 35 | ExQStringListModel.ui 36 | 37 | # Default rules for deployment. 38 | qnx: target.path = /tmp/$${TARGET}/bin 39 | else: unix:!android: target.path = /opt/$${TARGET}/bin 40 | !isEmpty(target.path): INSTALLS += target 41 | -------------------------------------------------------------------------------- /QtQStringListModelEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQStringListModel.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQStringListModel w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQTableWidgetEx/images/Image002.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTableWidgetEx/images/Image002.ico -------------------------------------------------------------------------------- /QtQTableWidgetEx/images/Image003.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTableWidgetEx/images/Image003.ico -------------------------------------------------------------------------------- /QtQTableWidgetEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQTableWidget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQTableWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQTableWidgetEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTableWidgetEx/qt.ico -------------------------------------------------------------------------------- /QtQTableWidgetEx/resoure.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image002.ico 4 | images/Image003.ico 5 | 6 | 7 | -------------------------------------------------------------------------------- /QtQTreeWidgetEx/QtQTreeWidgetEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-09-04T00:32:28 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQTreeWidgetEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQTreeWidget.cpp 30 | 31 | HEADERS += \ 32 | ExQTreeWidget.h 33 | 34 | FORMS += \ 35 | ExQTreeWidget.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | 44 | RESOURCES += \ 45 | resources.qrc 46 | -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image001.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image002.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image003.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image003.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image004.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image005.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image006.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image007.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image008.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image009.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image010.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image011.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image012.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image013.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image013.ico -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image014.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image014.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image015.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image015.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/image/Image016.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/image/Image016.jpg -------------------------------------------------------------------------------- /QtQTreeWidgetEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQTreeWidget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQTreeWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQTreeWidgetEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQTreeWidgetEx/qt.ico -------------------------------------------------------------------------------- /QtQTreeWidgetEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/Image001.jpg 4 | image/Image002.jpg 5 | image/Image003.jpg 6 | image/Image004.jpg 7 | image/Image005.jpg 8 | image/Image006.jpg 9 | image/Image007.jpg 10 | image/Image008.jpg 11 | image/Image009.jpg 12 | image/Image010.jpg 13 | image/Image011.jpg 14 | image/Image012.jpg 15 | image/Image013.ico 16 | image/Image014.jpg 17 | image/Image015.jpg 18 | image/Image016.jpg 19 | 20 | 21 | -------------------------------------------------------------------------------- /QtQVariant/QtQVariant.pro: -------------------------------------------------------------------------------- 1 | QT -= gui 2 | 3 | CONFIG += c++11 console 4 | CONFIG -= app_bundle 5 | 6 | # You can make your code fail to compile if it uses deprecated APIs. 7 | # In order to do so, uncomment the following line. 8 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 9 | 10 | SOURCES += \ 11 | main.cpp 12 | 13 | # Default rules for deployment. 14 | qnx: target.path = /tmp/$${TARGET}/bin 15 | else: unix:!android: target.path = /opt/$${TARGET}/bin 16 | !isEmpty(target.path): INSTALLS += target 17 | -------------------------------------------------------------------------------- /QtQVariant/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | class C{}; //自定义类型 6 | //Q_DECLARE_METATYPE(C) 7 | 8 | int main() 9 | { 10 | QVariant v('a'); // QVariant 没有专门的 char 构造函数,此处的字符 a 会被转换为 int 型,因此 v中存储的是数值 97,而不是字符 a 。 11 | cout<()<()< //因为要使用 QObject 类,为此需要包含此头文件 5 | class A:public QObject{ 6 | Q_OBJECT //启动元对象系统,必须声明此宏 7 | public: 8 | //定义 2 个构造函数、1 个信号、3 个函数。 9 | Q_INVOKABLE A(){} //要想函数被反射,需要指定 Q_INVOKABLE 宏。 10 | Q_INVOKABLE A(int){} 11 | Q_INVOKABLE void f(){} 12 | Q_INVOKABLE void g(int i,float j){} 13 | void g1(){} //注意:此函数不会被反射。 14 | signals: void gb3(); 15 | }; 16 | 17 | class B:public A{ 18 | Q_OBJECT //要使用元对象系统,应在每个类之中都声明此宏 19 | public: 20 | //定义 1 个函数、2 个信号 21 | Q_INVOKABLE void f(){} 22 | signals: void gb4(); 23 | void gb5(); 24 | }; 25 | 26 | #endif // M_H 27 | 28 | -------------------------------------------------------------------------------- /QtQcomboBoxEx/ExQcomboBox.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQCOMBOBOX_H 2 | #define EXQCOMBOBOX_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQcomboBox; 8 | } 9 | 10 | class ExQcomboBox : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQcomboBox(QWidget *parent = nullptr); 16 | ~ExQcomboBox(); 17 | 18 | private slots: 19 | void on_btnLeftInit_clicked(); 20 | void on_btnLeftClear_clicked(); 21 | void on_checkBoxOnlyWrite_clicked(); 22 | void on_btnRightInit_clicked(); 23 | void on_btnBottomAdd_clicked(); 24 | void on_btnBottomClear_clicked(); 25 | void on_checkBoxOnlyRead_clicked(); 26 | void onSelectDisplay(QString str); 27 | 28 | private: 29 | Ui::ExQcomboBox *ui; 30 | }; 31 | 32 | #endif // EXQCOMBOBOX_H 33 | -------------------------------------------------------------------------------- /QtQcomboBoxEx/QtQcomboBoxEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-26T23:53:34 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQcomboBoxEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQcomboBox.cpp 30 | 31 | HEADERS += \ 32 | ExQcomboBox.h 33 | 34 | FORMS += \ 35 | ExQcomboBox.ui 36 | 37 | RC_ICONS += images/qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | 44 | RESOURCES += \ 45 | resources.qrc 46 | -------------------------------------------------------------------------------- /QtQcomboBoxEx/images/github.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQcomboBoxEx/images/github.ico -------------------------------------------------------------------------------- /QtQcomboBoxEx/images/gril.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQcomboBoxEx/images/gril.ico -------------------------------------------------------------------------------- /QtQcomboBoxEx/images/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQcomboBoxEx/images/qt.ico -------------------------------------------------------------------------------- /QtQcomboBoxEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQcomboBox.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQcomboBox w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQcomboBoxEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/github.ico 4 | images/gril.ico 5 | 6 | 7 | -------------------------------------------------------------------------------- /QtQdialQLCDEx/ExQdialQLCD.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQdialQLCD.h" 2 | #include "ui_ExQdialQLCD.h" 3 | 4 | ExQdialQLCD::ExQdialQLCD(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::ExQdialQLCD) 7 | { 8 | ui->setupUi(this); 9 | 10 | //notchesVisible:表盘的小刻度是否可见 11 | //notchTarget:表盘刻度间间隔的像素值 12 | connect(ui->dial, SIGNAL(valueChanged(int)), this, SLOT(onDisplayLCD(int))); 13 | setWindowTitle(QObject::tr("QDial表盘输入,在LCD以多种进制显示")); 14 | } 15 | 16 | ExQdialQLCD::~ExQdialQLCD() 17 | { 18 | delete ui; 19 | } 20 | 21 | void ExQdialQLCD::onDisplayLCD(int val) 22 | { 23 | ui->lcdNumber->display(val); 24 | } 25 | 26 | void ExQdialQLCD::on_raidBtn2_clicked() //设置LCD显示二进制数 27 | { 28 | ui->lcdNumber->setBinMode(); 29 | } 30 | 31 | void ExQdialQLCD::on_raidBtn8_clicked() //设置LCD显示八进制数 32 | { 33 | ui->lcdNumber->setOctMode(); 34 | } 35 | 36 | void ExQdialQLCD::on_raidBtn10_clicked() //设置LCD显示十进制数 37 | { 38 | ui->lcdNumber->setDecMode(); 39 | } 40 | 41 | void ExQdialQLCD::on_raidBtn16_clicked() //设置LCD显示十六进制数 42 | { 43 | ui->lcdNumber->setHexMode(); 44 | } 45 | -------------------------------------------------------------------------------- /QtQdialQLCDEx/ExQdialQLCD.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQDIALQLCD_H 2 | #define EXQDIALQLCD_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class ExQdialQLCD; 8 | } 9 | 10 | class ExQdialQLCD : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit ExQdialQLCD(QWidget *parent = nullptr); 16 | ~ExQdialQLCD(); 17 | 18 | public slots: 19 | void onDisplayLCD(int val); 20 | 21 | private slots: 22 | void on_raidBtn2_clicked(); 23 | 24 | void on_raidBtn8_clicked(); 25 | 26 | void on_raidBtn10_clicked(); 27 | 28 | void on_raidBtn16_clicked(); 29 | 30 | private: 31 | Ui::ExQdialQLCD *ui; 32 | }; 33 | 34 | #endif // EXQDIALQLCD_H 35 | -------------------------------------------------------------------------------- /QtQdialQLCDEx/QtQdialQLCDEx.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-08-22T21:45:53 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = QtQdialQLCDEx 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | main.cpp \ 29 | ExQdialQLCD.cpp 30 | 31 | HEADERS += \ 32 | ExQdialQLCD.h 33 | 34 | FORMS += \ 35 | ExQdialQLCD.ui 36 | 37 | RC_ICONS += qt.ico 38 | 39 | # Default rules for deployment. 40 | qnx: target.path = /tmp/$${TARGET}/bin 41 | else: unix:!android: target.path = /opt/$${TARGET}/bin 42 | !isEmpty(target.path): INSTALLS += target 43 | -------------------------------------------------------------------------------- /QtQdialQLCDEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQdialQLCD.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQdialQLCD w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQdialQLCDEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQdialQLCDEx/qt.ico -------------------------------------------------------------------------------- /QtQlistWidgetEx/ExQListWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef EXQLISTWIDGET_H 2 | #define EXQLISTWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class ExQListWidget; 10 | } 11 | 12 | class ExQListWidget : public QMainWindow 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit ExQListWidget(QWidget *parent = nullptr); 18 | ~ExQListWidget(); 19 | 20 | private slots: 21 | void on_actListInit_triggered(); //初始化ListWidget 22 | void on_actInsert_triggered(); //插入item 23 | void on_actAdd_triggered(); //添加item 24 | void on_actClear_triggered(); //清除所有item 25 | void on_actDel_triggered(); //删除item 26 | void on_actSelAll_triggered(); //选中所有item 27 | void on_actSelNone_triggered(); //全部不选所有的item 28 | void on_actSelInvs_triggered(); //反选已筛选的item 29 | void on_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); //显示当前item的变动 30 | void on_listWidget_customContextMenuRequested(const QPoint &pos); //ListWidget弹出鼠标右键菜单 31 | void on_actExit_triggered(); //退出软件 32 | 33 | private: 34 | void setActionForToolBtn(); //创建cation和toolButton的关联 35 | void creatorPopMenu(); //创建两个单独的弹出式菜单的ToolButton 36 | 37 | private: 38 | Ui::ExQListWidget *ui; 39 | }; 40 | 41 | #endif // EXQLISTWIDGET_H 42 | -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/List.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/List.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/TREE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/TREE.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/Table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/Table.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/add.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/clear.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/delete.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/exit.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/github.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/gril.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/gril.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/init.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/insert.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/images/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/images/menu.png -------------------------------------------------------------------------------- /QtQlistWidgetEx/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExQListWidget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExQListWidget w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtQlistWidgetEx/qt.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtQlistWidgetEx/qt.ico -------------------------------------------------------------------------------- /QtQlistWidgetEx/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/add.png 4 | images/clear.png 5 | images/delete.png 6 | images/init.png 7 | images/insert.png 8 | images/List.png 9 | images/Table.png 10 | images/TREE.png 11 | images/github.png 12 | images/gril.png 13 | images/exit.png 14 | images/menu.png 15 | 16 | 17 | -------------------------------------------------------------------------------- /QtSigSlot/QtSigSlot.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++11 6 | 7 | # You can make your code fail to compile if it uses deprecated APIs. 8 | # In order to do so, uncomment the following line. 9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 10 | 11 | SOURCES += \ 12 | main.cpp \ 13 | mainwindow.cpp 14 | 15 | HEADERS += \ 16 | mainwindow.h 17 | 18 | FORMS += \ 19 | mainwindow.ui 20 | 21 | # Default rules for deployment. 22 | qnx: target.path = /tmp/$${TARGET}/bin 23 | else: unix:!android: target.path = /opt/$${TARGET}/bin 24 | !isEmpty(target.path): INSTALLS += target 25 | -------------------------------------------------------------------------------- /QtSigSlot/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 | -------------------------------------------------------------------------------- /QtSigSlot/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | #include 5 | #include 6 | 7 | MainWindow::MainWindow(QWidget *parent) 8 | : QMainWindow(parent) 9 | , ui(new Ui::MainWindow) 10 | { 11 | ui->setupUi(this); 12 | 13 | setWindowTitle(tr("信号和槽:Qt4 与 Qt5 用法")); 14 | ui->pushButton->setText(tr("关闭窗口")); 15 | 16 | // Qt4 方式 17 | // connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(closeWindow())); // 式1 18 | // connect(ui->pushButton, SIGNAL(clicked()), SLOT(closeWindow())); // 式2 19 | 20 | // Qt5 方式 21 | connect(ui->pushButton, &QPushButton::clicked, this, &MainWindow::closeWindow); // 式3 22 | // connect(ui->pushButton, &QPushButton::clicked, [=](){ // 式4 23 | // close(); 24 | // }); 25 | // connect(ui->pushButton, ui->pushButton->metaObject()->method(34), this, this->metaObject()->method(25)); // 式5 26 | 27 | 28 | 29 | // for (int var = 0; var < metaObject()->methodCount(); ++var) { 30 | // QMetaMethod qm1 = ui->pushButton->metaObject()->method(var); 31 | // QMetaMethod qm2 = this->metaObject()->method(var); 32 | // qDebug()< 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class MainWindow; } 8 | QT_END_NAMESPACE 9 | 10 | class MainWindow : public QMainWindow 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | MainWindow(QWidget *parent = nullptr); 16 | ~MainWindow(); 17 | 18 | private slots: 19 | void closeWindow(); 20 | 21 | private: 22 | Ui::MainWindow *ui; 23 | }; 24 | #endif // MAINWINDOW_H 25 | -------------------------------------------------------------------------------- /QtSigSlot/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 240 21 | 110 22 | 141 23 | 71 24 | 25 | 26 | 27 | 关闭窗口 28 | 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 0 36 | 800 37 | 21 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image1.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image2.jpg -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image3.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image4.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image5.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/Image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/Image6.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/icon.icns -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpClient/images/icon.ico -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExTcpClient.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExTcpClient w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtTcpEx/ExTcpClient/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image5.png 4 | images/Image4.png 5 | images/Image2.jpg 6 | images/Image1.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image1.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image2.jpg -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image3.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image4.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image5.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/Image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/Image6.png -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/icon.icns -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtTcpEx/ExTcpServer/images/icon.ico -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/images/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Image6.png 4 | Image3.png 5 | Image2.jpg 6 | Image1.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /QtTcpEx/ExTcpServer/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExTcpServer.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExTcpServer w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image1.png -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image2.jpg -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image3.png -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image4.png -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image5.png -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/Image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/Image6.png -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/icon.icns -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExMulticast/images/icon.ico -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExMulticast.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExMulticast w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtUdpEx/ExMulticast/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image1.png 4 | images/Image2.jpg 5 | images/Image4.png 6 | images/Image5.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image1.png -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image2.jpg -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image3.png -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image4.png -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image5.png -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/Image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/Image6.png -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/icon.icns -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/QtUdpEx/ExTrans/images/icon.ico -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ExTrans.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | ExTrans w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /QtUdpEx/ExTrans/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/Image1.png 4 | images/Image2.jpg 5 | images/Image3.png 6 | images/Image4.png 7 | images/Image5.png 8 | images/Image6.png 9 | 10 | 11 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/AbstractFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "AbstractFactory.h" 2 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/DesignPatterns.cpp: -------------------------------------------------------------------------------- 1 | // DesignPatterns.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | 6 | //int main() 7 | //{ 8 | // std::cout << "Hello World!\n"; 9 | //} 10 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/FactoryMethod.cpp: -------------------------------------------------------------------------------- 1 | #include "FactoryMethod.h" 2 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/Observer.cpp: -------------------------------------------------------------------------------- 1 | #include "Observer.h" 2 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/Singleton.cpp: -------------------------------------------------------------------------------- 1 | #include "Singleton.h" 2 | -------------------------------------------------------------------------------- /Studio/DesignPatterns/Singleton.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * Copyright (c) 2022~2023 XMuli All rights reserved. 3 | * GitHub: https://github.com/XMuli 4 | * Description: 单例模式 Singleton Pattern 的最优雅实现 5 | * Reference: https://zhuanlan.zhihu.com/p/37469260 单例介绍及好一篇 6 | ******************************************************************/ 7 | #pragma once 8 | 9 | // 推荐使用 →《Effective C++》提出了一种更优雅的单例模式实现,称为 Meyers' Singleton 10 | class Singleton 11 | { 12 | public: 13 | static Singleton& instance() { 14 | static Singleton instan; 15 | return instan; 16 | } 17 | 18 | private: 19 | Singleton() {}; 20 | ~Singleton() {}; 21 | Singleton(const Singleton& obj) = delete; 22 | Singleton& operator=(const Singleton& obj) = delete; 23 | }; 24 | 25 | //--------------------------------------------------------- 26 | // 不推荐使用 → Eager Singleton 是线程安全的,但存在潜在问题 no-local static 对象在不同编译单元中的初始化顺序是未定义的 27 | class Singleton2 28 | { 29 | public: 30 | static Singleton2& instance() { 31 | return instan; 32 | } 33 | 34 | private: 35 | Singleton2() {}; 36 | ~Singleton2() {}; 37 | Singleton2(const Singleton2&) = delete; 38 | Singleton2& operator=(const Singleton2&) = delete; 39 | 40 | private: 41 | static Singleton2 instan; 42 | }; 43 | 44 | Singleton2 Singleton2::instan; 45 | 46 | -------------------------------------------------------------------------------- /Studio/Studio/BinarySearch.cpp: -------------------------------------------------------------------------------- 1 | #include "BinarySearch.h" 2 | -------------------------------------------------------------------------------- /Studio/Studio/MemoryAlignment.h: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * Copyright (c) 2022~2023 XMuli All rights reserved. 3 | * GitHub: https://github.com/XMuli 4 | * Description: 类中字节对齐判断 5 | ******************************************************************/ 6 | 7 | // NOTE: 8 | #pragma once 9 | class A 10 | { 11 | private: 12 | int m_a; 13 | char m_c1; 14 | char m_c2; 15 | 16 | static int g_sta; 17 | }; // 8 18 | 19 | class B 20 | { 21 | public: 22 | void fun() {}; 23 | 24 | private: 25 | char m_c1; 26 | int m_a; 27 | char m_c2; 28 | }; // 12 29 | 30 | class C 31 | { 32 | public: 33 | virtual void fun() {}; 34 | 35 | private: 36 | int m_a; 37 | }; // 8 38 | -------------------------------------------------------------------------------- /Studio/Studio/SharedPtr.cpp: -------------------------------------------------------------------------------- 1 | #include "SharedPtr.h" 2 | -------------------------------------------------------------------------------- /Studio/Studio/SpecialMembers.cpp: -------------------------------------------------------------------------------- 1 | #include "SpecialMembers.h" 2 | -------------------------------------------------------------------------------- /Studio/Studio/Studio.cpp: -------------------------------------------------------------------------------- 1 | // Studio.cpp : This file contains the 'main' function. Program execution begins and ends there. 2 | // 3 | 4 | #include 5 | 6 | //int main() 7 | //{ 8 | // std::cout << "Hello World!\n"; 9 | //} -------------------------------------------------------------------------------- /Studio/Studio/UniquePtr.cpp: -------------------------------------------------------------------------------- 1 | #include "UniquePtr.h" 2 | -------------------------------------------------------------------------------- /TestHotKey/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(PROJECT_NAME TestHotKey) 3 | 4 | project(${PROJECT_NAME} VERSION 0.1 LANGUAGES CXX) 5 | 6 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 7 | 8 | set(CMAKE_AUTOUIC ON) 9 | set(CMAKE_AUTOMOC ON) 10 | set(CMAKE_AUTORCC ON) 11 | 12 | set(CMAKE_CXX_STANDARD 11) 13 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 14 | 15 | find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) 16 | find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) 17 | 18 | file(GLOB_RECURSE USER_LIBS_PATH QHotkey/**) 19 | 20 | set(PROJECT_SOURCES 21 | ${USER_LIBS_PATH} 22 | main.cpp 23 | widget.cpp 24 | widget.h 25 | tray.h 26 | tray.cpp 27 | Resources.qrc 28 | ) 29 | 30 | include_directories(${CMAKE_SOURCE_DIR}/QHotkey) 31 | 32 | add_executable(${PROJECT_NAME} 33 | ${PROJECT_SOURCES}) 34 | 35 | target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) 36 | 37 | set_target_properties(${PROJECT_NAME} PROPERTIES 38 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 39 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 40 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 41 | ) 42 | 43 | if(QT_VERSION_MAJOR EQUAL 6) 44 | qt_finalize_executable(${PROJECT_NAME}) 45 | endif() 46 | -------------------------------------------------------------------------------- /TestHotKey/QHotkey/QHotkey: -------------------------------------------------------------------------------- 1 | #include "qhotkey.h" 2 | -------------------------------------------------------------------------------- /TestHotKey/QHotkey/QHotkey.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = lib 2 | win32: CONFIG += dll 3 | 4 | TARGET = QHotkey 5 | VERSION = 1.5.0 6 | 7 | include(../qhotkey.pri) 8 | 9 | DEFINES += QHOTKEY_SHARED QHOTKEY_LIBRARY 10 | 11 | # use INSTALL_ROOT to modify the install location 12 | headers.files = $$PUBLIC_HEADERS 13 | headers.path = $$[QT_INSTALL_HEADERS] 14 | target.path = $$[QT_INSTALL_LIBS] 15 | INSTALLS += target headers 16 | 17 | -------------------------------------------------------------------------------- /TestHotKey/QHotkey/qhotkey.pri: -------------------------------------------------------------------------------- 1 | message(The pri file has been moved one directory up! use that one instead) 2 | -------------------------------------------------------------------------------- /TestHotKey/Resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/PicShot_32.svg 4 | 5 | 6 | -------------------------------------------------------------------------------- /TestHotKey/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019~2022 偕臧 All rights reserved. 3 | * 4 | * Author: XMuli xmulitech@gmail.com 5 | * 6 | * GitHub: https://github.com/XMuli 7 | * Blog: https://ifmet.cn 8 | * CSDN: https://blog.csdn.net/qq_33154343 9 | */ 10 | #include "widget.h" 11 | 12 | #include 13 | #include "tray.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | QApplication a(argc, argv); 18 | 19 | Tray* tary = new Tray(); 20 | QApplication::setQuitOnLastWindowClosed(false); 21 | 22 | return a.exec(); 23 | } 24 | -------------------------------------------------------------------------------- /TestHotKey/resources/PicShot_32.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /TestHotKey/tray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019~2022 偕臧 All rights reserved. 3 | * 4 | * Author: XMuli xmulitech@gmail.com 5 | * 6 | * GitHub: https://github.com/XMuli 7 | * Blog: https://ifmet.cn 8 | * CSDN: https://blog.csdn.net/qq_33154343 9 | */ 10 | #ifndef TRAY_H 11 | #define TRAY_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | class Tray : public QObject 20 | { 21 | Q_OBJECT 22 | public: 23 | explicit Tray(QObject *parent = nullptr); 24 | 25 | public slots: 26 | void onScreenShot(); 27 | 28 | private: 29 | QAction* m_screenShot; 30 | QAction* m_quit; 31 | QMenu* m_menuTary; 32 | QSystemTrayIcon* m_sysTary; 33 | 34 | QHotkey* m_hkScrnShot; // 热键 35 | }; 36 | 37 | #endif // TRAY_H 38 | -------------------------------------------------------------------------------- /TestHotKey/widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019~2022 偕臧 All rights reserved. 3 | * 4 | * Author: XMuli xmulitech@gmail.com 5 | * 6 | * GitHub: https://github.com/XMuli 7 | * Blog: https://ifmet.cn 8 | * CSDN: https://blog.csdn.net/qq_33154343 9 | */ 10 | #ifndef WIDGET_H 11 | #define WIDGET_H 12 | 13 | #include 14 | 15 | class Widget : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | static Widget& instance(); 21 | void getScrnShots(); 22 | ~Widget(); 23 | 24 | private: 25 | Widget(QWidget *parent = nullptr); 26 | 27 | protected: 28 | virtual void keyPressEvent(QKeyEvent *event) override; 29 | virtual void mouseMoveEvent(QMouseEvent *event) override; 30 | virtual void paintEvent(QPaintEvent *event) override; 31 | 32 | private: 33 | QPoint m_pos; 34 | }; 35 | #endif // WIDGET_H 36 | -------------------------------------------------------------------------------- /www.regexlab.com_zh_encoding.htm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMuli/QtExamples/927cae63369f0951ead406d40e013f3f0e9ae51a/www.regexlab.com_zh_encoding.htm.png --------------------------------------------------------------------------------