Toolbox Qt
Loading...
Searching...
No Matches
Public Member Functions | List of all members
tbq::QmlHelper Class Reference

Class containing multiple helpful methods that can be used in QML. More...

Inheritance diagram for tbq::QmlHelper:
Inheritance graph
[legend]
Collaboration diagram for tbq::QmlHelper:
Collaboration graph
[legend]

Public Member Functions

 QmlHelper (QObject *parent=nullptr)
 
Q_INVOKABLE bool qtVersionCheck (int major, int minor, int patch) const
 Use to verify Qt version.
 

Detailed Description

Class containing multiple helpful methods that can be used in QML.

This class group multiple methods that we can use inside QML files.
In order to use it, this class must be exposed to QML context property:

1#include <QGuiApplication>
2#include <QQmlApplicationEngine>
3#include <QQmlContext>
4
5int main(int argc, char *argv[])
6{
7 QGuiApplication app(argc, argv);
8
9 /* Load engine */
10 QQmlApplicationEngine engine;
11 //[...]
12
13 /* Set context properties */
14 tbq::QmlHelper qmlHelper;
15 engine.rootContext()->setContextProperty("qmlHelper", &qmlHelper);
16
17 /* Load QML modules */
18 //[...]
19
20 return app.exec();
21}
Class containing multiple helpful methods that can be used in QML.
Definition: qmlhelper.h:12

Member Function Documentation

◆ qtVersionCheck()

bool tbq::QmlHelper::qtVersionCheck ( int  major,
int  minor,
int  patch 
) const

Use to verify Qt version.

Can be used to dynamically manage function compatibilities:

Window{
width: 1000
height: 800
visible: true
title: qsTr("Hello world window title")
Component.onCompleted:{
if(qmlHelper.qtVersionCheck(6, 0, 0)){
console.info("Qt6 (or superior) version detected")
}else{
console.info("Qt5 (or inferior) version detected")
}
}
}
Parameters
[in]majorMajor version to check
[in]minorMinor version to check
[in]patchPatch version to check
Returns
Returns true if Qt version is superior or equal to argument version

The documentation for this class was generated from the following files: