Results 1 to 13 of 13

Thread: WIN32 + Barcode

  1. #1
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default WIN32 + Barcode

    Does anybody know how could I print barcodes with qt? Or Is there any example for this?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: WIN32 + Barcode

    Use a free barcode font, put it inside your application, use QPixmap, QPainter, drawText and use the image everywhere you want.

  3. #3
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    Thank you, but is there any example who did this before? Where could I find a free font?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: WIN32 + Barcode

    Quote Originally Posted by aekilic View Post
    Thank you, but is there any example who did this before?
    Come on, that's not that difficult!
    Qt Code:
    1. QString text = "CODE";
    2. QFont font("Trebuchet MS");
    3. QFontMetrics fm(font);
    4. QRect bound = fm.boundingRect(text);
    5. bound.moveTo(0,0);
    6. QPixmap pix(bound.size());
    7. pix.fill(Qt::white);
    8. QPainter p(&pix);
    9. p.setFont(font);
    10. p.setPen(QPen(Qt::black,1,Qt::SolidLine));
    11. p.drawText(bound, Qt::AlignCenter, text);
    12. p.end();
    To copy to clipboard, switch view to plain text mode 

    Where could I find a free font?
    Google -> barcode font free : Code 39

  5. #5
    Join Date
    Apr 2009
    Location
    Aviano, North Italy
    Posts
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    The answer would depend on what barcode you need to use. As far as I know Code 39 is simple enough as it has a 1:1 relationship from character to glyph. On the other hand EAN-13/UPC which is used in commerce has a complex relationship where the final glyph depends on the original character, its position in the string, its parity and the phase of the moon.

    As it happens, I have just finished a first attempt at printing EAN-13 barcodes to a laser printer and had success both reading and scanning the results.

    If you are interested I can send you a copy of the class - it works but it could probably be improved. Also, the moon-phase bit is not yet implemented

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: WIN32 + Barcode

    Quote Originally Posted by gwyn View Post
    If you are interested I can send you a copy of the class - it works but it could probably be improved.
    Maybe others also would like to see the code. If it is no company secret It would be nice if you could post it here or create a new wiki entry for that.

  7. #7
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    yes, we do need a new wiki entry..hasnt been any new one for a LONG time..plus it would be interesting to know how u maintained EAN-13/UPC, cuz it sounds hard

  8. #8
    Join Date
    Apr 2009
    Location
    Aviano, North Italy
    Posts
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    ok, I'll attempt a wiki then repost here when done.

  9. #9
    Join Date
    Apr 2009
    Location
    Aviano, North Italy
    Posts
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    For all interested parties the article is up on the wiki under examples.

    I would appreciate proof-reading and comments

    Cheers all

  10. The following 3 users say thank you to gwyn for this useful post:

    aekilic (14th May 2009), Lykurg (14th May 2009), talk2amulya (14th May 2009)

  11. #10
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    great article! well documented, very informative..superb job..thanks gwyn

  12. #11
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: WIN32 + Barcode

    Thanks for the article, I just have added a function to change the barcode after the instance was created.

  13. #12
    Join Date
    Apr 2009
    Location
    Aviano, North Italy
    Posts
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    Glad you like it. If this meets aekilic's needs perhaps the thread should be marked as solved?

  14. #13
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: WIN32 + Barcode

    that will solve all my problems..... thank you very very much

Similar Threads

  1. Qt on win32 question
    By mzeal in forum Installation and Deployment
    Replies: 2
    Last Post: 15th April 2009, 13:21
  2. Using a Win32 static library
    By jacky in forum Qt Programming
    Replies: 2
    Last Post: 15th April 2009, 04:39
  3. Launching and handling posix or win32 signals
    By Althor in forum Qt Programming
    Replies: 2
    Last Post: 20th November 2008, 07:34
  4. win32 platform macros?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 20:02
  5. QDialog in the taskbar (Win32)
    By Arthur in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2006, 16:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.