Skip to content

Latest commit

 

History

History
125 lines (94 loc) · 6.22 KB

README.en.md

File metadata and controls

125 lines (94 loc) · 6.22 KB

Qt-App

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!

Qt-App

CrashReport

crash reporting program;

Code structure

  1. cmake: Encapsulated CMake utility function;

    1. utils: Utility function;
  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: Plug-ins are inherited here;

    5. dump: Crash capture function;

      1. breakpad: Crash capture based on Google Breakpad package;

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

        Under unix systems, you may need tocrashpad_handlerGrant execution permission, otherwise it will not start normally.

        chmod +x crashpad_handler
    6. extensionsystem: Plug-in system, the code comes from Qt-Creator, with some modifications;

    7. gui: Encapsulated interface component;

    8. plugins:Plug-in;

      1. aboutplugin:About the plug-in;
      2. coreplugin: Core plug-in, 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, the 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 a file;

Questions and comments

  • MacOS, the bundle generated by cmake is not generated in the .app/Contents/ folderPkgInfodocument;

    1. 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;
    2. How does cmake generate PkgInfo files?
      1. WireShark useset_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/PkgInfo PROPERTIES MACOSX_PACKAGE_LOCATION .)In a similar way, copy it to the bundle;
    3. qmake will generate a PkgInfo file by default, you only need to specifyTARGET=apporCONFIG+=bundleThat’s it;
  • Under Unix systems, you need to use static libraries as much as possible to avoid dependence on dynamic libraries;

    1. Several modules in this project are dynamic libraries, and because they are plugins, they need to be loaded dynamically;
    2. 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;
    3. Or use install_name_tool (macos), 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 do not package them repeatedly;
    5. For details, please seeworkflows
  • MacOS,vcpkgIssues with compiling third-party libraries;

    1. becausevcpkgat presentOnly supports separate compilation of x64-osx and arm64-osx
    2. In usecmake, you need to specifyCMAKE_OSX_ARCHITECTURES=x86_64orCMAKE_OSX_ARCHITECTURES=arm64;
    3. In useqmake, you need to specifyQMAKE_APPLE_DEVICE_ARCHS=x86_64orQMAKE_APPLE_DEVICE_ARCHS=arm64
  • International real-time translation. After changing the translation settings, you need to restart the program to take effect;

    1. Command to update translations
    ```bash
     cmake --build build --target Qt-App_lupdate
    ```
    
    1. Too lazy to change the code;

    2. 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;
         }
      }