View Full Version : drawing barcode with GNU Barcode

14th December 2010, 13:57
Hi. I'm developing a report design application. I want the user to be able to add some types of barcode like EAN-13, CODE-39, CODE-128 etc. I use GNU Barcode library to create the barcodes. The library generates a PostScript file and I read the x, y, width and height values from the PostScript file and I save the each bar as a QRectF object.
I draw the bars with QPainter::drawRect() function. If any two bars are very close to each other(like 0,15), the space between them disappears and they seem as a wider single bar so the barcode reader cannot read the barcode that I printed to a page. Maybe the float values in the QRectF object are casted to integer inside the QPainter class. I would appreciate any suggestions to draw this barcode in another way please.

14th December 2010, 15:56
You could try this : EAN-13_Barcode_class (http://www.qtcentre.org/wiki/index.php?title=EAN-13_Barcode_class)


14th December 2010, 16:44
Are you sure that your pen width isnt causing your bars to run into one another ? Try using a thinner pen.

15th December 2010, 08:55
I set the pen to Qt::NoPen already. I also tried to draw the bars thinner but it couldn't be read by the barcode reader.