Getting values from pro files in Qt

Getting values from pro files in Qt

Asked on January 10, 2019 in Qt.
Add Comment


  • 2 Answer(s)

    values from pro files in Qt:

    DEFINES += VERSION=\\\"$$VERSION\\\"
    
    

    The  macro  use the C source code  to get the backslashes and quotes  number not a string.

    Answered on January 10, 2019.
    Add Comment

    The simole statement is:

    YourApp.pro:

    VERSION = 0.0.0.1
    DEFINES += APP_VERSION=\\\"$$VERSION\\\"
    

    The main.cpp:

    #include <QApplication>
    QCoreApplication::setApplicationVersion(QString(APP_VERSION));
    

    Source code is controller.cpp:

    #include <QApplication>
    QString yourAppVersion = QCoreApplication::applicationVersion();
    
    Answered on January 10, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.