Skip to content

Latest commit

 

History

History
196 lines (134 loc) · 9.95 KB

README.en.md

File metadata and controls

196 lines (134 loc) · 9.95 KB

Some simple common examples of Qt

Battery——Battery control

BatteryQuick--battery control(QtQuick

Bootstarp--Auto-start settings and detection when the program is powered on

  1. Reading and writing the registry under Windows enables self-starting at boot, and there are two locations where you can write;

    HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run //对于所有用户
    HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run // 对于当前用户
  2. Copy the plist file to ~/Library/LaunchAgents/ under MacOS, and use the launchctl load/unload command to achieve automatic startup at boot;

  3. There are two ways under Ubuntu:

    1. Use the systemctl --user enable/disable command to achieve automatic startup at boot;
      1. Copy the .service and .timer files to ~/.config/systemd/user/, and use the systemctl --user enable/disable command to implement automatic startup at boot;
      2. The systemctl command is used in the .timer file, which is used to execute the .service file regularly to prevent the qxcbconnection: could not connect to display error from occurring after the graphical interface is started;
    2. Copy the .desktop file under /usr/share/Application/ to ~/.config/autostart/ to achieve automatic startup at boot (not verified);

BubbleWindow——Bubble dialog box, which can also be used as a tool tip (ToolTip)

Chart——Visual chart drawing, referenceUse QChart to display real-time dynamic curvesExamples related to QChart

图一、二动态曲线
图二坐标轴也会滚动

CheckBoxStandardItem——StandardItem that can be checked, and the parent node status or child node status is automatically updated according to the checked status

Clock--clock

DashBoard——Dashboard

DragDrop——Simple control drag and drop, refer to the QT example Drag and Drop Puzzle Example

FlowLayout——Flow layout, from QT example Flow Layout Example

GridViewModel——Adaptive palace chart based on QListView

HttpClient——http client

IconButton——EventFilter and Button that support Icon following state switching

ImageCarousel——Simple image carousel component

LogAsynchronous——Asynchronous logging, create a thread to write logs to files, and separate the front and back ends

  1. Log file name: application name (appname). time (time, accurate to seconds). host name. process ID (Tid). log (. count). If a single log written in a day is close to 1G, a suffix will be added automatically. (.1,.2.3..., and so on) Create a new log file to write, and rollFile will still be rolled at 0 o'clock every day;
    1. Normal file name: LogAsynchronous.2020-04-26-20-29-03.Youth.11828.log;
    2. The log written on that day was close to 1G, and the new file name was: LogAsynchronous.2020-04-26-20-38-55.Youth.11828.log.1;
  2. Log format: time (time, accurate to milliseconds). Thread ID (Pid). Log level (debug). Print information (msg). File (File). Line number (Line).
    1. For example: 2020-04-26 20:38:55.818 2052[Debug]123456789qwertyuioplkjhgfdsa 8412789-File:(..\logAsynchronous\main.cpp) Line:(19);
  3. Qt-App, this project also has log encapsulation, which is roughly consistent with the code of this project. Since the update frequency of the two projects may be different, it is recommended to check the log module at the same time.Qt-Applatest updates.

MulClient——Multi-threaded client, one client per thread (how to bypass system limitations and simulate millions of clients)

MulServer——Multi-threaded server, one thread and one client processing (processing TCP communication with high real-time performance)

NavigationProgressBar——Navigation progress bar

PasswordLineEdit——Password input box

ProgressArc——Arc progress bar

ProgressBar——QProgressBar rounded corner alternative

ReactorServer——Multi-threaded server, Reactor mode (Echo)

SimpleUdp——Simple UDP example, broadcast and receive

ShowInMyComputer——Show current applications in My Computer

Firewall whitelist.

SlipButton——Sliding button

Another: A simpler implementation:Animated CheckBox

SqliteWAL——Multi-threaded concurrent writing database program in Sqlite WAL mode

Advantages of WAL mode

  1. Improved concurrency: WAL mode allows multiple readers and one writer to access the database at the same time, which can improve concurrency and performance;
  2. Crash recovery: WAL mode ensures that the database remains consistent in the event of a crash by flushing all changes to the log file before committing the transaction;
  3. Improved write performance: WAL mode allows concurrent writes, which can improve write performance better than the default rollback mode;

Things to note about WAL mode

  1. WAL mode is only available in SQLite 3.35.5+ versions;
  2. Increased disk usage: WAL mode requires more disk space than rollback mode because it writes all changes to the log file before committing them;
  3. Slow read performance: In WAL mode, read operations are not blocked by write operations. If read and write operations are performed at the same time, data inconsistency may result.

TableViewModel——Table view

  1. Various custom agents
    1. ButtonDelegate
    2. ComboBoxDelegate
    3. ProgressBarDelegate
    4. RichTextItemDelegate
    5. StarDelegate----From Qt example Star Delegate Example;
  2. One hundred thousand level data rendering;

Thread——Multi-threading examples, 6 ways of writing

TreeViewModel——Tree view (MVC), QtCreator source code

Validator——Enhanced versions of IntValidator (QIntValidator) and DoubleValidator (QDoubleValidator)

packaging——Packaging script

  1. macos
    1. qmakecompile;
    2. Package pkg and dmg packages and sign them (python/appdmg), for details, please refer toQt-App
  2. ubuntu
    1. qmakecompile;
    2. For packaging deb packages, please refer toQt-App
  3. windows
    1. qmakecompile;
    2. signtoolsign;
    3. Inno Setup packaging can be referred toQt-App, if you want to sign, you can putsign.batCopy the signature script in the Inno Setup toolTools->Configure Sign Tools, then add sign flags after the required files;