Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Access QBS variables in Qt code
Forum Updated to NodeBB v4.3 + New Features

Access QBS variables in Qt code

Scheduled Pinned Locked Moved Unsolved General and Desktop
qbsqtcreatorqt5
2 Posts 2 Posters 672 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CybeX
    wrote on 26 Oct 2018, 18:13 last edited by CybeX
    #1

    Good day.

    I need to access specific QBS variables inside my Qt code.

    An example is the Application's name, organisation or even the flavour, all variables specified like this in my application qbs file.

    import qbs
    
    Project {
    
        // These variables should be available in C++ code.
        name: "my_app_name"
        organization: "Organisation_Name"
        flavour:"AppFlavour"
        minimumQbsVersion: "1.7.1"
    
        CppApplication {
            files: [
            ]
            Depends { name: "Qt"; submodules: ['core', 'network'] }
    
            cpp.cxxLanguageVersion: "c++11"
    
            cpp.defines: [
                "QT_DEPRECATED_WARNINGS",
            ]
    
            consoleApplication: true
    
            Group {
                name: "source"
                files: [
                    "qconfigurationmanager.cpp",
                ]
            }
    
            Group {
                name: "header"
                files: [
                    "qconfigurationmanager.h",
                ]
            }
    
            Group {     // Properties for the produced executable
                fileTagsFilter: "application"
                qbs.install: true
            }
        }
    }
    

    Looking at the Qt documentation for QBS, I did not find any reference to using QBS variables in Qt code.

    This is the only link of using QBS variables, but only within the QBS file

    I would like to do this:

    QString appflavour = Qbs.get("flavour")
    

    How can I do this?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 26 Oct 2018, 18:24 last edited by
      #2

      Define your variables via cpp.defines and use from C++.

      1 Reply Last reply
      2

      1/2

      26 Oct 2018, 18:13

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved