the panel printer only accept hex code.
The panel accepts a series of bytes. For your convenience you can express them in decimal, hexadecimal, octal, or ASCII characters in your source code. The panel doesn't care, it just accepts the bytes.
You don't tell us what type 'ls' is, but QByteArray is probably the best match for your task.
#include <QtCore>
int main(int argc, char* argv[])
{
int a = 3;
int b = 53;
ls += 0x1b; // hex
ls += 39; // decimal
ls += '\0'; // as a character
ls += 015; // octal
ls += static_cast<char>(a); // explicit cast from int
ls += b; // implicit cast from int
// send the byte array
qDebug() << ls.toHex();
return 0;
}
#include <QtCore>
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
int a = 3;
int b = 53;
QByteArray ls;
ls += 0x1b; // hex
ls += 39; // decimal
ls += '\0'; // as a character
ls += 015; // octal
ls += static_cast<char>(a); // explicit cast from int
ls += b; // implicit cast from int
// send the byte array
qDebug() << ls.toHex();
return 0;
}
To copy to clipboard, switch view to plain text mode
You could more conveniently initialise the fixed data in the array like:
QByteArray ls = QByteArray::fromHex("1b27000d");
To copy to clipboard, switch view to plain text mode
then append a and b.
Bookmarks