Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. From .pro file how to access a variable from another file?

From .pro file how to access a variable from another file?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qmakepro file
3 Posts 2 Posters 975 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.
  • N Offline
    N Offline
    Nmaster88
    wrote on last edited by
    #1

    I don't understand much of qmake and haven't find on documentation anything about this topic.

    What i'm looking to do is, i want to access a variable that can be define inside a .js or .py file and use it on a QT .pro file.

    Something like this:

    VAR_VERSION = getVariableValue($$PWD/file.js,"var_version")
    

    where getVariableValue would be a way (parser or similar) to get the variable var_version value that is inside the file.js file.

    This can be impossible to do, or there may be some way to get a variable value, or the content of a file somehow.

    Anyone knows a way of doing it?

    jsulmJ 1 Reply Last reply
    0
    • N Nmaster88

      I don't understand much of qmake and haven't find on documentation anything about this topic.

      What i'm looking to do is, i want to access a variable that can be define inside a .js or .py file and use it on a QT .pro file.

      Something like this:

      VAR_VERSION = getVariableValue($$PWD/file.js,"var_version")
      

      where getVariableValue would be a way (parser or similar) to get the variable var_version value that is inside the file.js file.

      This can be impossible to do, or there may be some way to get a variable value, or the content of a file somehow.

      Anyone knows a way of doing it?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Nmaster88 I don't understand the use case: why do you want to parse a file to get value of a variable? Can you explain what you want to achieve? Also, variables are often initialised at runtime - you would not get any meaningful value for such a variable if your would parse the source code.
      Usually one executes such a script which then returns a value.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • N Offline
        N Offline
        Nmaster88
        wrote on last edited by Nmaster88
        #3

        we would like to install different builds on the same machine and the place were would do that distinction would be on the .pro file, to then generate different values for the "version" value of "info.plist" file.

        We already have a portion of code that we can probably use to do something similar:

        codegen.commands = python "\"$${PATH}/Dir1/test.py\""
        !isEmpty(VARNAME) {
            message($$VARNAME)
            codegen.commands += VarName=$$CONFNAME
        }
        

        I think we are getting there

        1 Reply Last reply
        0

        • Login

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