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. [SOLVED] How to compare value of a custom variable with constant in the *.pro file?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to compare value of a custom variable with constant in the *.pro file?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.8k 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.
  • _ Offline
    _ Offline
    _Dima
    wrote on 1 Apr 2014, 15:08 last edited by
    #1

    Could you please advise how does equals function work?

    I wont to use "equals ":https://qt-project.org/doc/qt-5.1/qmake/qmake-test-function-reference.html#equals-variablename-value function in the pro file:
    _equals(variablename, value)
    Tests whether variablename equals the string value.
    For example:
    TARGET = helloworld
    equals(TARGET, "helloworld") {
    message("The target assignment was successful.")
    }
    _

    So I've created following test pro file:
    @
    QT += core gui widgets

    TEMPLATE = app
    test_variable = 1

    message(test variable value = $$test_variable)

    equals(test_variable, "1")
    {
    message("1")
    }

    equals(test_variable, "2")
    {
    message("2")
    }
    @

    In the result I have :
    Project MESSAGE: test variable value = 1
    Project MESSAGE: 1
    Project MESSAGE: 2

    So both cases are occurred! I was trying equals($$(test_variable), "1") and it also doesn't work.

    How Can I compare custom variable value with any constant (or value of other variable)?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on 1 Apr 2014, 15:17 last edited by
      #2

      This code works. Note the curly brackets on the same line with equals.

      @
      test_variable = 1

      message(test variable value = $$test_variable)

      equals(test_variable, "1") { <---- here
      message("1")
      }

      equals(test_variable, "2") { <--- and here
      message("2")
      }
      @

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        _Dima
        wrote on 1 Apr 2014, 15:27 last edited by
        #3

        Yes, this variant (the curly brackets on the same line with equals) works.
        I'm shocked...

        Thank you very much for your help!

        1 Reply Last reply
        0

        1/3

        1 Apr 2014, 15:08

        • Login

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