Barcodes generated not readable how to fix it?
-
I wrote this code in which the barcode is generated, but when scanned it is not read how to fix it?
void MainWindow::on_pushButton_clicked()
{
QString barcodeText = "Welcome";
int id = QFontDatabase::addApplicationFont("E:/QT Offline/Qt5.12.12/Barcode/Code_128.ttf");
QFontDatabase::applicationFontFamilies(id).at(0);
QFont barcodefont = QFont("code 128", 150, QFont::Normal);
barcodefont.setLetterSpacing(QFont::AbsoluteSpacing,0.0);
this->ui->label->setFont(barcodefont);
this->ui->label->setText(barcodeText);
}Output:-
-
@Ramkumar-Mohan said in Barcodes generated not readable how to fix it?:
QFontDatabase::applicationFontFamilies(id).at(0);
That line does nothing useful, but I do not think that is your problem
Your barcode does not include the start, check, stop, and final bar symbols required in a Code-128 barcode.
This is what it should look like:
-
@Ramkumar-Mohan said in Barcodes generated not readable how to fix it?:
QFontDatabase::applicationFontFamilies(id).at(0);
That line does nothing useful, but I do not think that is your problem
Your barcode does not include the start, check, stop, and final bar symbols required in a Code-128 barcode.
This is what it should look like:
-
@Ramkumar-Mohan Did you read the link @ChrisW67 provided? Wikipedia has all the information you need. You should think of the bar code as individual character bytes instead of a full string. First, combine all the byte you need to be displayed using a QByteArray. Also, you need to encode all the characters in the right way. 'W' in the way you are using it has the ASCII value 0x58. However, the table for Code-128 on Wikipedia says it is 0x37. Only if you choose code set B can you use lower case letters. Furthermore, you need to compute the checksum and add it as well. I also don't have any clue about Code-128, but Wikipedia provides all the information you need.
Most likely the best you can do is provide a lookup table to translate ASCII to Code-128 (most likely Code Set B). Note, that there is only the English alphabet plus a few accented characters. Certainly, you don't have full Unicode available. This restricts the languages you can use with Code-128.
-
I think this question is not quite Qt-related ><
Since it is about some standard, just search in github, you can find some useful projects, like https://github.com/adamgiacomelli/Qt-barcode.
This project send barcodes to printer, but you can find useful codes in BarcodePrinter::encodeBarcode
What you need is to encode the string like in this project before set the text to the label. -
I think this question is not quite Qt-related ><
Since it is about some standard, just search in github, you can find some useful projects, like https://github.com/adamgiacomelli/Qt-barcode.
This project send barcodes to printer, but you can find useful codes in BarcodePrinter::encodeBarcode
What you need is to encode the string like in this project before set the text to the label.Now , working fine Thank you...
-
I wrote this code in which the barcode is generated, but when scanned it is not read how to fix it?
void MainWindow::on_pushButton_clicked()
{
QString barcodeText = "Welcome";
int id = QFontDatabase::addApplicationFont("E:/QT Offline/Qt5.12.12/Barcode/Code_128.ttf");
QFontDatabase::applicationFontFamilies(id).at(0);
QFont barcodefont = QFont("code 128", 150, QFont::Normal);
barcodefont.setLetterSpacing(QFont::AbsoluteSpacing,0.0);
this->ui->label->setFont(barcodefont);
this->ui->label->setText(barcodeText);
}Output:-
@Ramkumar-Mohan
@JonB
How to save only the scene in graphics view. actual scene width and scene height.