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. TCHAR and WinAPI functions setting in qmake
Forum Updated to NodeBB v4.3 + New Features

TCHAR and WinAPI functions setting in qmake

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 5 Posters 1.5k 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #2

    change char buffer[MAX_PATH] = { 0 }; to std::remove_pointer<LPTSTR>::type buffer[MAX_PATH];

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #3

      You can call GetCurrentDirectoryA directly. But why would you use MBCS in the first place?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      aha_1980A 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        You can call GetCurrentDirectoryA directly. But why would you use MBCS in the first place?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #4
        This post is deleted!
        1 Reply Last reply
        0
        • S Offline
          S Offline
          spaghetti.coder
          wrote on last edited by
          #5

          @VRonin @Christian-Ehrlicher You are right! But do you take into account that it is an artificial example? If it was my problem, I wouldn't ask it here. I have a huge legacy project, which was built with Qt 4. I would like to transfer it on Qt 5, but I have a lot of error which are similar with the one from the sample. I wouldn't like to make thousands char -> TCHAR replacements (or others), I would like to update existing pro file, if it is possible. It would be much simplier and much more effective.

          aha_1980A 1 Reply Last reply
          0
          • S spaghetti.coder

            @VRonin @Christian-Ehrlicher You are right! But do you take into account that it is an artificial example? If it was my problem, I wouldn't ask it here. I have a huge legacy project, which was built with Qt 4. I would like to transfer it on Qt 5, but I have a lot of error which are similar with the one from the sample. I wouldn't like to make thousands char -> TCHAR replacements (or others), I would like to update existing pro file, if it is possible. It would be much simplier and much more effective.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @spaghetti.coder

            If I remember correctly the define UNICODE or _UNICODE is responsible for that. So you would need to un-define this symbol.

            You can read a bit more about that here: https://blogs.msdn.microsoft.com/oldnewthing/20040212-00/?p=40643/

            1 Reply Last reply
            1
            • S Offline
              S Offline
              spaghetti.coder
              wrote on last edited by
              #7

              @aha_1980 Yes, you are right. I tried to use constructions like

              DEFINES += _MBCS
              DEFINES += MBCS
              DEFINES -= _UNICODE
              DEFINES -= UNICODЕ
              

              in the pro file, but it didn't help.

              aha_1980A 1 Reply Last reply
              0
              • S spaghetti.coder

                @aha_1980 Yes, you are right. I tried to use constructions like

                DEFINES += _MBCS
                DEFINES += MBCS
                DEFINES -= _UNICODE
                DEFINES -= UNICODЕ
                

                in the pro file, but it didn't help.

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @spaghetti.coder please show a compiler command line from the compile log. Maybe give a corresponding line from the project against Qt4.

                I remember having done something like this some years ago, but I will not be able to look into it before next week.

                PS: If you disable unicode, your program will have problems with non ASCII path names. It might work on your machine, but on a different language it could be complete garbage. But that should have been already the case before.

                S 1 Reply Last reply
                2
                • aha_1980A aha_1980

                  @spaghetti.coder please show a compiler command line from the compile log. Maybe give a corresponding line from the project against Qt4.

                  I remember having done something like this some years ago, but I will not be able to look into it before next week.

                  PS: If you disable unicode, your program will have problems with non ASCII path names. It might work on your machine, but on a different language it could be complete garbage. But that should have been already the case before.

                  S Offline
                  S Offline
                  spaghetti.coder
                  wrote on last edited by
                  #9

                  @aha_1980

                  DEFINES += MBCS
                  DEFINES -= UNICODE
                  

                  works! But it was necessary to remove the build folder. Clean wasn't enough for some unclear reasons.

                  JKSHJ S 2 Replies Last reply
                  1
                  • S spaghetti.coder

                    @aha_1980

                    DEFINES += MBCS
                    DEFINES -= UNICODE
                    

                    works! But it was necessary to remove the build folder. Clean wasn't enough for some unclear reasons.

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #10

                    @spaghetti.coder said in TCHAR and WinAPI functions setting in qmake:

                    it was necessary to remove the build folder. Clean wasn't enough for some unclear reasons.

                    The cleaner checks the Makefile to find out what files should be deleted. This means the cleaner can't (won't) delete the Makefile itself.

                    However, changing the .pro file renders the existing Makefile out-of-date, so you need to generate a new Makefile. The two ways to do so are:

                    • Delete the existing Makefile (which you did when you removed the build folder) and run the whole build process from scratch, or
                    • Run qmake

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    S 1 Reply Last reply
                    2
                    • S spaghetti.coder

                      @aha_1980

                      DEFINES += MBCS
                      DEFINES -= UNICODE
                      

                      works! But it was necessary to remove the build folder. Clean wasn't enough for some unclear reasons.

                      S Offline
                      S Offline
                      spaghetti.coder
                      wrote on last edited by
                      #11

                      @spaghetti.coder Actually DEFINES -= UNICODE is enough (:

                      1 Reply Last reply
                      1
                      • JKSHJ JKSH

                        @spaghetti.coder said in TCHAR and WinAPI functions setting in qmake:

                        it was necessary to remove the build folder. Clean wasn't enough for some unclear reasons.

                        The cleaner checks the Makefile to find out what files should be deleted. This means the cleaner can't (won't) delete the Makefile itself.

                        However, changing the .pro file renders the existing Makefile out-of-date, so you need to generate a new Makefile. The two ways to do so are:

                        • Delete the existing Makefile (which you did when you removed the build folder) and run the whole build process from scratch, or
                        • Run qmake
                        S Offline
                        S Offline
                        spaghetti.coder
                        wrote on last edited by
                        #12

                        @JKSH I thought I had rerun qmake, but who knows...

                        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