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. Qt with Visual Studio macro issue
Forum Update on Monday, May 27th 2025

Qt with Visual Studio macro issue

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 2.1k 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #1

    Hi! I want to open my Qt project in Visual Studio for more advance debugging. The problem is it not recognize one defined constant from Qt pro file.

    Code:
    Qt pro file:
    QMAKE_TARGET_NAME = My App Test
    DEFINES += APP_NAME=$$shell_quote(\"$$QMAKE_TARGET_NAME\")

    Works normal in Qt IDE. In Visual Studio 2015 displays error - user-defined literal operator not found (#define APP_NAME ""My App Test"").

    So how to make it compatible with Visual Studio 2015 and Qt?

    1 Reply Last reply
    0
    • Cobra91151C Offline
      Cobra91151C Offline
      Cobra91151
      wrote on last edited by Cobra91151
      #2

      The problem is with wrong escape, in Visual Studio it displays double quotes around My App Test (APP_NAME constant). How to escape properly? Thanks in advance.

      1 Reply Last reply
      0
      • Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by
        #3

        How to make special characters such as char(32) work in Qt pro file? Thanks.

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

          Hi,

          Isn't that because you are already quoting the result before calling shell_quote ?

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

          Cobra91151C 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            Isn't that because you are already quoting the result before calling shell_quote ?

            Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by Cobra91151
            #5

            @SGaist

            Without quotes it's not working in Qt. Throws errors such as C2065: 'My': undeclared identifier and C2146: syntax error: missing ')' before identifier 'App'.

            The $$shell_quote(\"$$QMAKE_TARGET_NAME\") function works in Qt but not in Visual Studio.

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

              That's the problem with complex defines, each application and terminal might handle them differently.

              One alternative could be to generate a header file that contains that kind of contents and that you'll include in your application code.

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

              Cobra91151C 1 Reply Last reply
              0
              • SGaistS SGaist

                That's the problem with complex defines, each application and terminal might handle them differently.

                One alternative could be to generate a header file that contains that kind of contents and that you'll include in your application code.

                Cobra91151C Offline
                Cobra91151C Offline
                Cobra91151
                wrote on last edited by
                #7

                @SGaist

                Thanks. It's now compatible with Qt and Visual Studio 2015.

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

                  You're welcome !

                  What did you implement to make it work ?

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

                  Cobra91151C 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    You're welcome !

                    What did you implement to make it work ?

                    Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on last edited by
                    #9

                    @SGaist

                    The solution is to create C++ header file with APP_NAME constant and include it where it requires. Now it's compatible with Qt and Visual Studio 2015.

                    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