developer/new-developers/qt-qml-coding-style: linkify

Change-Id: I3fdd81f7463aa2100aa9192c0b1708934810dcfb
This commit is contained in:
ovari123 2025-01-18 00:12:49 -04:00 committed by ovari123@zoho.com
parent cbbd6e21f0
commit 417d82ed74
1 changed files with 17 additions and 11 deletions

View File

@ -1,10 +1,14 @@
Qt and QML coding style
=======================
# Qt and QML coding style
## Qt/C++
## Qt/c++
### Signal and slot naming
Both signals and slots should use camelCase.
A signal should use the simple past tense or past participle of some verb, likely prefixed by a short subject. A corresponding slot should be the signal prefixed with the word "on" and not the word "slot". Here are some examples:
A signal should use the simple past tense or past participle of some verb, likely prefixed by a short subject.
A corresponding slot should be the signal prefixed with the word "on" and not the word "slot".
Here are some examples:
```c
// correct
signal:
@ -25,14 +29,16 @@ slot:
void slotNavigateToHomeView();
```
---
## QML
## Code formatting
The Qt 5.15.0 version of qmlformat has some issues dealing with comment sections and currently does not discriminate against max columns, so we will continue to format using these guidelines for now.
The following is a comprehensive sample component, adapted from https://doc.qt.io/qt-5/qml-codingconventions.html, that attempts to illustrate the ideally formatted component.
### Code formatting
The Qt 5.15.0 version of qmlformat has some issues dealing with comment sections and currently does not discriminate against max columns, so this formatting style will continue to be used in the guidelines.
The following is a comprehensive sample component, adapted from <https://doc.qt.io/qt-5/qml-codingconventions.html>, that attempts to illustrate the ideally formatted component.
```javascript
/*
* authored by/copyright ...
* authored by/copyright
*/
// Id always on the first line, and always present and called root
@ -45,11 +51,11 @@ Rectangle {
id: root
// property declarations
property bool thumbnail: false
property bool thumbnail: false
property alias image: photoImage.source
// signal declarations
signal clicked
signal clicked
// javascript functions
function doSomething(x) {