georgeky
25th July 2011, 14:28
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:
QPrinter printer;
QPainter painter;
painter.begin(&printer);
double scaleFactor;
scaleFactor = 1.0;
QFont barcodefont = QFont("Code128", 32, QFont::Normal);
barcodefont.setLetterSpacing(QFont::AbsoluteSpacin g,1.0);
painter.setFont(barcodefont);
char mytext[20];
mytext[0]= 204;
mytext[1]=77;
mytext[2]=72;
mytext[3]=66;
mytext[4]=45;
mytext[5]=54;
mytext[6]=84;
mytext[7]=71;
mytext[8]=45;
mytext[9]=54;
mytext[0]=84;
mytext[11]=71;
mytext[12]=45;
mytext[13]=71;
mytext[14]=71;
mytext[15]=72;
mytext[16]=74;
mytext[17]=104;
mytext[18]=206;
mytext[19]=0;
qDebug() << mytext;
painter.drawText(-30, 370,mytext);
painter.end();
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:
QPrinter printer;
QPainter painter;
painter.begin(&printer);
double scaleFactor;
scaleFactor = 1.0;
QFont barcodefont = QFont("Code128", 32, QFont::Normal);
barcodefont.setLetterSpacing(QFont::AbsoluteSpacin g,1.0);
painter.setFont(barcodefont);
char mytext[20];
mytext[0]= 204;
mytext[1]=77;
mytext[2]=72;
mytext[3]=66;
mytext[4]=45;
mytext[5]=54;
mytext[6]=84;
mytext[7]=71;
mytext[8]=45;
mytext[9]=54;
mytext[0]=84;
mytext[11]=71;
mytext[12]=45;
mytext[13]=71;
mytext[14]=71;
mytext[15]=72;
mytext[16]=74;
mytext[17]=104;
mytext[18]=206;
mytext[19]=0;
qDebug() << mytext;
painter.drawText(-30, 370,mytext);
painter.end();