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 Updated to NodeBB v4.3 + New Features

Qt with Visual Studio macro issue

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 2.1k 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.
  • C Offline
    C Offline
    Cobra91151
    wrote on 24 Feb 2017, 14:51 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
    • C Offline
      C Offline
      Cobra91151
      wrote on 24 Feb 2017, 19:24 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
      • C Offline
        C Offline
        Cobra91151
        wrote on 25 Feb 2017, 14:11 last edited by
        #3

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

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Feb 2017, 22:40 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

          C 1 Reply Last reply 26 Feb 2017, 19:41
          1
          • S SGaist
            25 Feb 2017, 22:40

            Hi,

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

            C Offline
            C Offline
            Cobra91151
            wrote on 26 Feb 2017, 19:41 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
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 26 Feb 2017, 20:54 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

              C 1 Reply Last reply 27 Feb 2017, 09:24
              0
              • S SGaist
                26 Feb 2017, 20:54

                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.

                C Offline
                C Offline
                Cobra91151
                wrote on 27 Feb 2017, 09:24 last edited by
                #7

                @SGaist

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

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 27 Feb 2017, 15:10 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

                  C 1 Reply Last reply 20 Apr 2017, 18:49
                  0
                  • S SGaist
                    27 Feb 2017, 15:10

                    You're welcome !

                    What did you implement to make it work ?

                    C Offline
                    C Offline
                    Cobra91151
                    wrote on 20 Apr 2017, 18:49 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