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. QMake: Use string as variable
Forum Updated to NodeBB v4.3 + New Features

QMake: Use string as variable

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 302 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Alvaro Silva
    wrote on last edited by
    #1

    Hello,

    I have a string and I want to use it as part of another variable name

    QT_MODULE_NAME = xml
    
    # I would like to use something like this:
    LIB_PATH = $${QT.$${QT_MODULE_NAME}.libs}
    

    But it does not seem to work. I get Missing } terminator

    Any tips?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I don't think qmake supports nesting variable names like that. One thing you could try is to use different scoping methods:

      LIB_PATH = $${QT.$${QT_MODULE_NAME}.libs}
      # Or
      LIB_PATH = $${QT.$$(QT_MODULE_NAME).libs}
      # Or
      LIB_PATH = $${QT.${QT_MODULE_NAME}.libs}
      

      Dig through qmake documentation, maybe it will help.

      Alternative would be to build an array and iterate over it, like:

      QT_MODULE_NAMES = QT.xml QT.widgets QT.networking
      QT_MODULE_NAMES += QT.gui
      for (module, QT_MODULE_NAMES) {
        LIB_PATH=module.libs
      }
      

      I have no idea if it will work with variable names - I doubt it.

      (Z(:^

      1 Reply Last reply
      3
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #3

        Hi, try:

        LIB_PATH = $$eval(QT.$${QT_MODULE_NAME}.libs)
        
        1 Reply Last reply
        1

        • Login

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