I am having a major issue printing a readable barcode from QT on an epson M-T500 printer thermal receipt printer.

i am using the font from http://www.dafont.com/code-128.font

It prints th ebarcode but somehow its not printing the correct order

I even tried to hardcode the char with ascii code still does not work.

Any help will be much appreciated.

The Barcode text: MHB-6TG-6TG-GGHJ

My sample code:

Qt Code:
  1. QPrinter printer;
  2. QPainter painter;
  3. painter.begin(&printer);
  4. double scaleFactor;
  5. scaleFactor = 1.0;
  6. QFont barcodefont = QFont("Code128", 32, QFont::Normal);
  7. barcodefont.setLetterSpacing(QFont::AbsoluteSpacing,1.0);
  8. painter.setFont(barcodefont);
  9. char mytext[20];
  10.  
  11. mytext[0]= 204;
  12. mytext[1]=77;
  13. mytext[2]=72;
  14. mytext[3]=66;
  15. mytext[4]=45;
  16. mytext[5]=54;
  17. mytext[6]=84;
  18. mytext[7]=71;
  19. mytext[8]=45;
  20. mytext[9]=54;
  21. mytext[0]=84;
  22. mytext[11]=71;
  23. mytext[12]=45;
  24. mytext[13]=71;
  25. mytext[14]=71;
  26. mytext[15]=72;
  27. mytext[16]=74;
  28. mytext[17]=104;
  29. mytext[18]=206;
  30. mytext[19]=0;
  31. qDebug() << mytext;
  32. painter.drawText(-30, 370,mytext);
  33. painter.end();
To copy to clipboard, switch view to plain text mode