C++ namespace with consts in QML



  • Hello,

    I was wondering if it is possible to have C++ namespace with constants and somehow use those constants in the QML.

    Here is my namespace:

    namespace ProjectNameSpace
    {
    	extern const int PROJECT_BUILD;
    	extern const QString PROJECT_NAME;
    }
    

    Is it possible to use PROJECT_BUILD and PROJECT_NAME in the QML file?

    With best wishes,
    poor_robert


  • Lifetime Qt Champion

    Hi,

    Do you really need a namespace ?

    Otherwise you could make a QObject with e.g. read-only properties returning the values you want.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.