Jump to content

Qt6/Example-Guideline

From Qt Wiki
Revision as of 09:04, 17 January 2023 by Kileppal (talk | contribs)

When creating or updating Qt examples, developer should consider the best practises and guidelines listed in this document.

Evaluate if the example is meaningful or should it be removed/merged

MANDATORY

  • Check if there are similar examples for the same topic and consider if both are really needed or should the other one be merged with the other.
  • Check also documentation on the topic and if that includes inline code snippet that would be adequate instead of complete example.

No C++ or qml warnings

MANDATORY


RECOMMENDED
Consider also the compilation with the more strict warning flags and fix the found issues.
GCC

Clang

Visual Studio

Qt6 best practises and changes


MANDATORY

Leveraging C++17


RECOMMENDED

Naming the example, categorisation and adding keywords


MANDATORY

  • Don't add Qt module name or "Example" word to the example name. e.g. QtWidgets Application Example → Text editor application
    • Note: If the part of the module name really needs to be used due to clearly describing functionality, that can still be done (e.g. Simple CoAP Client Example from Qt CoAP module)
  • Add example application to correct category, for instance by adding '\meta category {Graphics & UI}' below '\examples'
 \example My Example 
 \meta category {My Category}

Will end up as

 <categories> 
   <category>My Category</category> 
 </categories>

in the <example> section of the respective examples-manifest.xml file.
For further details see: https://codereview.qt-project.org/c/qt/qttools/+/447246


RECOMMENDED

  • Confirm that the example shows up in Qt Creator welcome screen.
  • Check that the example description text shown in Creator contains the right keywords for users to find it.
  • Add appropriate tags to the example, for instance by adding '\meta tags {tag1,tag2}' below '\examples'.
  • Tags are used to set additional keywords for the example which makes it easier to search in Qt Creator example view
    • Don't add redundant information as tags which is already part of the category, example name or description
    • Don't add platform information in the tags