Picture resources etc. come from the Internet. This code repository is for learning only. If it is used for commercial purposes by others, it has nothing to do with me! Please obey the license!
- A plug-in development desktop application framework that can be used to quickly develop desktop applications;qt-creator/src/libs/extensionsystem at master · qt-creator/qt-creator (github.com);
- Cooperatevcpkgto use;
- Support bothcmakeandqmakecompile;
- Support Apple Silicon native compilation;
- supportactionsCompile, package and publish;
crash reporting program;
-
cmake: Encapsulated CMake utility function;
- utils: Utility function;
-
docs:Document description and pictures;
-
examples:Sample code;
-
packaging:Packaging and publishing;
-
src: source code;
-
3rdparty: Third-party library;
- qtlockedfile:Qt file lock;
- qtsingleapplication: Qt single instance;
-
aggregate:polymerization;
-
apps:app;
- app:Qt-App;
- crashreport:CrashReport;
-
core: Plug-ins are inherited here;
-
dump: Crash capture function;
-
extensionsystem: Plug-in system, the code comes from Qt-Creator, with some modifications;
-
gui: Encapsulated interface component;
-
plugins:Plug-in;
- aboutplugin:About the plug-in;
- coreplugin: Core plug-in, main interface, menu, toolbar, status bar, settings, plug-in manager, etc.;
- guiplugin: GUI plug-in, some GUI components customized based on QSS style;
- hashplugin: Hash plug-in, the hash algorithm provided by QT;
- helloplugin: Hello plug-in, used for testing plug-in development;
- systeminfoplugin: System information plug-in;
-
resource: Pictures and QSS files;
-
utils: Tool function encapsulation;
-
-
translations:translate a file;
-
MacOS, the bundle generated by cmake is not generated in the .app/Contents/ folder
PkgInfo
document;- app/CMakeLists, using this CMakeLists.txt, you can generate a bundle on MacOS and the icon can be displayed normally, but there is no PkgInfo file;
- How does cmake generate PkgInfo files?
- WireShark use
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/PkgInfo PROPERTIES MACOSX_PACKAGE_LOCATION .)
In a similar way, copy it to the bundle;
- WireShark use
- qmake will generate a PkgInfo file by default, you only need to specify
TARGET=app
orCONFIG+=bundle
That’s it;
-
Under Unix systems, you need to use static libraries as much as possible to avoid dependence on dynamic libraries;
- Several modules in this project are dynamic libraries, and because they are plugins, they need to be loaded dynamically;
- Then you need to package these dynamic libraries and load them at runtime. You also need to modify the rpath
"-Wl,-rpath,\'\$$ORIGIN\':\'\$$ORIGIN/lib\':'\$$ORIGIN/../lib'")
, set it, otherwise the dynamic library will not be found; - Or use install_name_tool (macos), patchelf/chrpath (linux) to modify the dependency path of the dynamic library, which is very troublesome;
- Also consider that these libraries can be shared, so do not package them repeatedly;
- For details, please seeworkflows;
-
MacOS,vcpkgIssues with compiling third-party libraries;
- becausevcpkgat presentOnly supports separate compilation of x64-osx and arm64-osx;
- In usecmake, you need to specify
CMAKE_OSX_ARCHITECTURES=x86_64
orCMAKE_OSX_ARCHITECTURES=arm64
; - In useqmake, you need to specify
QMAKE_APPLE_DEVICE_ARCHS=x86_64
orQMAKE_APPLE_DEVICE_ARCHS=arm64
;
-
International real-time translation. After changing the translation settings, you need to restart the program to take effect;
- Command to update translations
```bash cmake --build build --target Qt-App_lupdate ```
-
Too lazy to change the code;
-
Specific reference: QT practical tips (update as soon as I think of it), core code;
void Widget::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: comboBox->setItemText(0, tr("Hello")); label->setText(tr("Hello")); // 代码添加的文字 ui->retranslateUi(this); // 有UI文件情况下 break; default: break; } }