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. Barcode generation on Windows and Linux [Solved]
QtWS25 Last Chance

Barcode generation on Windows and Linux [Solved]

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 13.6k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I must develop an application that print some barcode (code 39) .
    The application should run on windows and linux.

    I know that on Windows it's possible using barcode font (for example IDAutomationHC39M) but what on Linux?

    Are there some Qt/C++ API that allow barcode generation?

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      "I think this one can be used for your case too: ":http://www.qtcentre.org/wiki/index.php?title=EAN-13_Barcode_class

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        [quote author="Eddy" date="1311416375"]"I think this one can be used for your case too: ":http://www.qtcentre.org/wiki/index.php?title=EAN-13_Barcode_class[/quote]

        Good link, thanks.
        For me it should be better the "Code 39".

        Now I found a way to install IDAutomationHC39M in my Slackware Linux so I can print with it both on linux and windows.

        I actually use the font this way:
        @
        ...
        ...
        painter.setFont(QFont("IDAutomationHC39M", 30));
        painter.drawText(rect(), Qt::AlignCenter, "123456789");
        ...
        @

        Is it possible to "embed" the font in my Qt application to avoid font installation on every system I use it?

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          I've never done it with a font, but you could try to add the file in a qrc file using the resource system.

          I hope it works.

          Edit : try to use it like this :
          @
          SetFont(":/fonts/yourfont");

          @

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • L Offline
            L Offline
            luca
            wrote on last edited by
            #5

            [quote author="Eddy" date="1311417465"]I've never done it with a font, but you could try to add the file in a qrc file using the resource system.

            I hope it works.

            Edit : try to use it like this :
            @
            SetFont(":/fonts/yourfont");

            @[/quote]

            It doesn't works.
            I think SetFont() doesn't accept a filename.

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6

              Try the following to add your font to your application :
              @int QFontDatabase::addApplicationFont ( const QString & fileName ) [static]@
              (please read the notes in the docs for linux)
              Use it like this :

              @QFontDatabase fontDatabase;
              fontDatabase.addApplicationFont(":/fonts/yourfont");@

              And then use setFont

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • jensen82J Offline
                jensen82J Offline
                jensen82
                wrote on last edited by
                #7

                Here is an interesting SDK for you: "Barcode SDK":http://www.leadtools.com/sdk/barcode/

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  luca
                  wrote on last edited by
                  #8

                  [quote author="Eddy" date="1311524605"]Try the following to add your font to your application :
                  @int QFontDatabase::addApplicationFont ( const QString & fileName ) [static]@
                  (please read the notes in the docs for linux)
                  Use it like this :

                  @QFontDatabase fontDatabase;
                  fontDatabase.addApplicationFont(":/fonts/yourfont");@

                  And then use setFont
                  [/quote]

                  Thanks a lot Eddy, it works!

                  I tried under Linux (Slackware 13.37) and it works without problem. I don't know why the documentation note say that:
                  @
                  Adding application fonts on Unix/X11 platforms without fontconfig is currently not supported.
                  @

                  1 Reply Last reply
                  0
                  • EddyE Offline
                    EddyE Offline
                    Eddy
                    wrote on last edited by
                    #9

                    You're welcome. I'm glad it works for you.

                    Maybe the note in the docs is from ancient times when it didn't work ;)

                    Have fun.

                    Qt Certified Specialist
                    www.edalsolutions.be

                    1 Reply Last reply
                    0
                    • Q Offline
                      Q Offline
                      qtbrandson
                      wrote on last edited by
                      #10

                      I only tried those which support Code 39 barcode generating using .NET app. It support C++, C#. You may search online.

                      <a href="http://www.aspper.com">generate barcode in .NET applications</a>

                      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