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. How to use CreateFont API function in Qt5
Forum Update on Monday, May 27th 2025

How to use CreateFont API function in Qt5

Scheduled Pinned Locked Moved Unsolved General and Desktop
createfont apiwinapi
19 Posts 3 Posters 6.2k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 20 May 2016, 22:36 last edited by SGaist
    #2

    Hi and welcome to devnet,

    It would rather be LIBS += -lGdi32.

    Out of curiosity, why not use Qt's QFont class ?

    [edit: Fixed casing SGaist]

    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
    0
    • U Offline
      U Offline
      Uncle Kris
      wrote on 21 May 2016, 13:29 last edited by
      #3

      The program was written using APIs originally. I like to compile and link it before I start to make changes.

      I have tried your solution. Same error.

      K 1 Reply Last reply 21 May 2016, 13:39
      0
      • U Uncle Kris
        21 May 2016, 13:29

        The program was written using APIs originally. I like to compile and link it before I start to make changes.

        I have tried your solution. Same error.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 21 May 2016, 13:39 last edited by
        #4

        @Uncle-Kris
        Do you have the windows SDKs installed? Did you make sure that the -L switch points to the correct path containing the import library files (.lib) and that you have -lgdi32 in your pro (that's a typo on part of @SGaist as the library is specified with a lowercase letter)?

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0
        • U Offline
          U Offline
          Uncle Kris
          wrote on 21 May 2016, 16:41 last edited by
          #5

          I see your point. No, SDK is not installed. I used to work in BCB 4 and all basic libraries were part of installation. I will look for them now.

          1 Reply Last reply
          0
          • U Offline
            U Offline
            Uncle Kris
            wrote on 21 May 2016, 19:46 last edited by
            #6

            I have installed SDK, updated path in .pro file. Same error.

            K 1 Reply Last reply 21 May 2016, 19:48
            0
            • U Uncle Kris
              21 May 2016, 19:46

              I have installed SDK, updated path in .pro file. Same error.

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 21 May 2016, 19:48 last edited by
              #7

              @Uncle-Kris
              Okay, what libraries does the SDK provide (for which compilers), do they match the compiler you're using? Can we see the line from the project where you set the link flags (i.e. LIBS += ...)?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • U Offline
                U Offline
                Uncle Kris
                wrote on 21 May 2016, 19:53 last edited by
                #8

                The line is:
                LIBS += -L"H:\Windows Kits\8.1\Lib\winv6.3\um\x86/gdi32"\

                There is no info on compiler dependency. Just folder full of libraries. How I can check?

                K 1 Reply Last reply 21 May 2016, 19:57
                0
                • U Uncle Kris
                  21 May 2016, 19:53

                  The line is:
                  LIBS += -L"H:\Windows Kits\8.1\Lib\winv6.3\um\x86/gdi32"\

                  There is no info on compiler dependency. Just folder full of libraries. How I can check?

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 21 May 2016, 19:57 last edited by kshegunov
                  #9

                  @Uncle-Kris
                  LIBS += -L"H:\Windows Kits\8.1\Lib\winv6.3\um\x86/gdi32"\

                  This is incomplete. The backslash at the end means it continues on to the next line. Also, when giving paths, use the forward slash instead of the a backwards. It is recognized on windows and you'll work around a ton of problems with escaping in the long run.

                  There is no info on compiler dependency. Just folder full of libraries. How I can check?

                  It should be noted somewhere on the MS's site, however I have no windows on hand to check. What compiler are you using currently? The 8.1 SDK should work with MSVC 2012/2013 if I recall correctly.

                  Read and abide by the Qt Code of Conduct

                  U 1 Reply Last reply 22 May 2016, 10:23
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 21 May 2016, 22:08 last edited by
                    #10

                    @kshegunov Not a typo ;) See here

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

                    K 1 Reply Last reply 21 May 2016, 22:19
                    0
                    • S SGaist
                      21 May 2016, 22:08

                      @kshegunov Not a typo ;) See here

                      K Offline
                      K Offline
                      kshegunov
                      Moderators
                      wrote on 21 May 2016, 22:19 last edited by
                      #11

                      @SGaist said:

                      It would rather be LIBS += -LGdi32.

                      I know, I know. Still looks like you typed -L instead of -l ;)

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 21 May 2016, 22:21 last edited by
                        #12

                        Haaaaaaa that typo ! Good catch ! Then indeed, there was ! :)

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

                        U 1 Reply Last reply 22 May 2016, 10:28
                        0
                        • K kshegunov
                          21 May 2016, 19:57

                          @Uncle-Kris
                          LIBS += -L"H:\Windows Kits\8.1\Lib\winv6.3\um\x86/gdi32"\

                          This is incomplete. The backslash at the end means it continues on to the next line. Also, when giving paths, use the forward slash instead of the a backwards. It is recognized on windows and you'll work around a ton of problems with escaping in the long run.

                          There is no info on compiler dependency. Just folder full of libraries. How I can check?

                          It should be noted somewhere on the MS's site, however I have no windows on hand to check. What compiler are you using currently? The 8.1 SDK should work with MSVC 2012/2013 if I recall correctly.

                          U Offline
                          U Offline
                          Uncle Kris
                          wrote on 22 May 2016, 10:23 last edited by
                          #13

                          @kshegunov There was a next line. I have removed it for test time. Also changes to shash/backslash do not make any difference for now. Linker is not happy.

                          1 Reply Last reply
                          0
                          • S SGaist
                            21 May 2016, 22:21

                            Haaaaaaa that typo ! Good catch ! Then indeed, there was ! :)

                            U Offline
                            U Offline
                            Uncle Kris
                            wrote on 22 May 2016, 10:28 last edited by
                            #14

                            @SGaist What typo? Can you be more specific, please? Compiler has no problem with that line. And it used to work in another IDE.

                            Also: "It would rather be LIBS += -LGdi32." No. Without full path there is a message that file is not found. -L and -l makes no difference so far.

                            K 1 Reply Last reply 22 May 2016, 11:16
                            0
                            • U Uncle Kris
                              22 May 2016, 10:28

                              @SGaist What typo? Can you be more specific, please? Compiler has no problem with that line. And it used to work in another IDE.

                              Also: "It would rather be LIBS += -LGdi32." No. Without full path there is a message that file is not found. -L and -l makes no difference so far.

                              K Offline
                              K Offline
                              kshegunov
                              Moderators
                              wrote on 22 May 2016, 11:16 last edited by
                              #15

                              @Uncle-Kris
                              A library is passed to qmake (respectively make) with the following syntax:

                              LIBS += -L/path/to/library -llibraryname
                              

                              The typo was that @SGaist used the switch for library path -L to specify the library name. It should've been -lgdi32. So in your case it'd look something like this:

                              LIBS += -L"H:/Windows Kits/8.1/Lib/winv6.3/um/x86" -lgdi32
                              

                              Read and abide by the Qt Code of Conduct

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 22 May 2016, 15:12 last edited by
                                #16

                                Yes the typo was the L vs l but still the library name is Gdi32

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

                                K 1 Reply Last reply 22 May 2016, 17:20
                                0
                                • S SGaist
                                  22 May 2016, 15:12

                                  Yes the typo was the L vs l but still the library name is Gdi32

                                  K Offline
                                  K Offline
                                  kshegunov
                                  Moderators
                                  wrote on 22 May 2016, 17:20 last edited by
                                  #17

                                  @SGaist said:

                                  but still the library name is Gdi32

                                  The windows linker isn't case sensitive. :)

                                  Read and abide by the Qt Code of Conduct

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 22 May 2016, 20:42 last edited by
                                    #18

                                    @kshegunov said:

                                    @SGaist said:

                                    but still the library name is Gdi32

                                    The windows linker isn't case sensitive. :)

                                    Indeed, but I wouldn't be surprised if that changed at some point :D

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

                                    K 1 Reply Last reply 22 May 2016, 20:48
                                    0
                                    • S SGaist
                                      22 May 2016, 20:42

                                      @kshegunov said:

                                      @SGaist said:

                                      but still the library name is Gdi32

                                      The windows linker isn't case sensitive. :)

                                      Indeed, but I wouldn't be surprised if that changed at some point :D

                                      K Offline
                                      K Offline
                                      kshegunov
                                      Moderators
                                      wrote on 22 May 2016, 20:48 last edited by kshegunov
                                      #19

                                      @SGaist said:

                                      Indeed, but I wouldn't be surprised if that changed at some point :D

                                      Perhaps, perhaps. Although, judging from the time it took MS to introduce the x64 compiler, if it were to change, it'd take decades. And since it hasn't changed for over 30 years, I really doubt that it ever will. :D

                                      Read and abide by the Qt Code of Conduct

                                      1 Reply Last reply
                                      0

                                      11/19

                                      21 May 2016, 22:19

                                      • Login

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