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. Best practice for setting Windows .exe properties with Qt Creator?
Qt 6.11 is out! See what's new in the release blog

Best practice for setting Windows .exe properties with Qt Creator?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.1k Views 2 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.
  • R Offline
    R Offline
    racingame
    wrote on last edited by racingame
    #1

    Is putting

    VERSION = 0.0.0.1
    QMAKE_TARGET_COMPANY = company
    QMAKE_TARGET_PRODUCT = product
    QMAKE_TARGET_DESCRIPTION = description
    QMAKE_TARGET_COPYRIGHT = copyright

    in the .pro file the best way to do it?

    Also, I was trying to make the appname and version to show on my app title, but somehow I get an error.

    I add these lines to the .pro file:

    DEFINES += APP_NAME=\"Test Name Application\"
    VERSION = 1.2.3
    DEFINES += APP_VERSION=\"$$VERSION\"

    and this line to the main.cpp file:

    w.setWindowTitle(QString(APP_NAME).replace("_"," ") + QString(" - ") + APP_VERSION);

    But I get the following errors when compiling:

    C2065: 'Test': identifier not declared
    C2228: left of '.replace' must have class/struct/union

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You're not escaping your quotes enough for your defines on Windows.

      An alternative would be to use QMAKE_SUBSTITUTES and generate a header which will contain the info you want.

      Hope it helps.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • R Offline
        R Offline
        racingame
        wrote on last edited by
        #3

        Actually, I can't understand. Couldn't you please provide the lines of codes you generally use for populating the properties fields for a Windows application?

        Paul ColbyP 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I was talking about your DEFINES.

          I usually used an rc file and haven't yet used QMAKE_TARGET_COMPANYand its friends.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • R racingame

            Actually, I can't understand. Couldn't you please provide the lines of codes you generally use for populating the properties fields for a Windows application?

            Paul ColbyP Offline
            Paul ColbyP Offline
            Paul Colby
            wrote on last edited by
            #5

            Hi @racingame,

            Couldn't you please provide the lines of codes you generally use for populating the properties fields for a Windows application?

            Like @SGaist, I tend you use my own rc file (just allows you to do a whole lot more than qmake is aware of), but you can see plenty of real-world examples on GitHub via a code search like this one: https://github.com/search?l=QMake&q=QMAKE_TARGET_COMPANY&type=Code

            As for:

            DEFINES += APP_NAME=\"Test Name Application\"
            VERSION = 1.2.3
            DEFINES += APP_VERSION=\"$$VERSION\"
            

            The problem here is that the arguments are not being escaped correctly when passed to the compiler. For this, I suggest you use QMake's shell_quote function like:

            DEFINES += APP_NAME=$$shell_quote(\"Test Name Application\")
            VERSION = 1.2.3
            DEFINES += APP_VERSION=$$shell_quote(\"$$VERSION\")
            

            Cheers.

            1 Reply Last reply
            3

            • Login

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