Skip to content

Files

125 lines (94 loc) · 6.2 KB

README.en.md

File metadata and controls

125 lines (94 loc) · 6.2 KB

Qt-App

图片资源等来自于互联网。 本代码仓库,仅供学习,若被他人用于商业用途 与本人无关! 请遵守许可证!

Qt-App

CrashReport

Crash reporting procedure;

Code structure

  1. cmake: Encapsulated CMake utility function;

    1. utils: Practical functions;
  2. docs: Document description and pictures;

  3. examples: Sample code;

  4. packaging: Packaging and publishing;

  5. src: Source code;

    1. 3rdparty: Third-party library;

      1. qtlockedfile: Qt file lock;
      2. qtsingleapplication: Qt single instance;
    2. aggregate:polymerization;

    3. apps:app;

      1. app:Qt-App;
      2. crashreport:CrashReport;
    4. core: Plugins are inherited from this;

    5. dump: Crash capture function;

      1. Breakpad: Crash capture based on Google Breakpad encapsulation;

      2. crashpad: Crash capture based on Google Crashpad encapsulation;

        Under Unix system, it may be necessarycrashpad_handlerGrant execution permissions, otherwise it will not start normally.

        chmod +x crashpad_handler
    6. extensionsystem: Plugin system, the code comes from Qt-Creator, and some modifications have been made;

    7. gui: Encapsulated interface components;

    8. plugins: Plugin;

      1. aboutplugin:About plugins;
      2. coreplugin: Core plug-ins, main interface, menu, toolbar, status bar, settings, plug-in manager, etc.;
      3. guiplugin: GUI plug-in, some GUI components customized based on QSS style;
      4. hashplugin: hash plug-in, hash algorithm provided by QT;
      5. helloplugin: Hello plug-in, used for testing plug-in development;
      6. systeminfoplugin: System information plug-in;
    9. resource: Pictures and QSS files;

    10. utils: Tool function encapsulation;

  6. translations: Translate the file;

Questions and Notes

  • MacOS, cmake generated bundle, not generated under .app/Contents/ folderPkgInfodocument;

    1. app/CMakeLists, using this CMakeLists.txt can generate bundles on MacOS, and the icons can be displayed normally, but there is no PkgInfo file;
    2. How to generate a PkgInfo file in cmake?
      1. Using WireSharkset_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/PkgInfo PROPERTIES MACOSX_PACKAGE_LOCATION .)Similarly, copy it to the bundle;
    3. qmake will generate PkgInfo file by default, you only need to specify itTARGET=apporCONFIG+=bundleJust do it;
  • Under Unix systems, it is necessary to use static libraries as much as possible to avoid the dependency problem of dynamic libraries;

    1. There are several modules in this project that are dynamic libraries because they are plugins and require dynamic loading;
    2. Then you need to package these dynamic libraries, then load them at runtime, and you also need to rpath"-Wl,-rpath,\'\$$ORIGIN\':\'\$$ORIGIN/lib\':'\$$ORIGIN/../lib'"), set it, otherwise the dynamic library will not be found;
    3. Or use install_name_tool(macos) and patchelf/chrpath(linux) to modify the dependency path of the dynamic library, which is very troublesome;
    4. Also consider that these libraries can be shared, so don't re-package them;
    5. You can see for detailsworkflows
  • MacOS,vcpkgCompiling third-party library issues;

    1. becausevcpkgat presentOnly support for individual compilation of x64-osx and arm64-osx
    2. In usecmakeWhen specifyingCMAKE_OSX_ARCHITECTURES=x86_64orCMAKE_OSX_ARCHITECTURES=arm64;
    3. In useqmakeWhen specifyingQMAKE_APPLE_DEVICE_ARCHS=x86_64orQMAKE_APPLE_DEVICE_ARCHS=arm64
  • International real-time translation. The translation settings are currently changed and the program needs to be restarted before it can take effect;

    1. Update the translation command
    ```bash
     cmake --build build --target Qt-App_lupdate
    ```
    
    1. I'm too lazy to change the code;

    2. Specific reference: QT practical tips (update when you 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;
         }
      }