Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Barcodes generated not readable how to fix it?
Forum Updated to NodeBB v4.3 + New Features

Barcodes generated not readable how to fix it?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 393 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by
    #1

    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:-

    bar.JPG

    Ramkumar MohanR 1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @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:
      Code128code.png

      Ramkumar MohanR 1 Reply Last reply
      2
      • C ChrisW67

        @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:
        Code128code.png

        Ramkumar MohanR Offline
        Ramkumar MohanR Offline
        Ramkumar Mohan
        wrote on last edited by Ramkumar Mohan
        #3

        @ChrisW67 @JonB

        Yes, It should be created as per this,,,

        878a6039-c995-437f-8e98-127f308c1003.png

        I have no idea how to do something like this , if you know how, please tell me .

        S 1 Reply Last reply
        0
        • Ramkumar MohanR Ramkumar Mohan

          @ChrisW67 @JonB

          Yes, It should be created as per this,,,

          878a6039-c995-437f-8e98-127f308c1003.png

          I have no idea how to do something like this , if you know how, please tell me .

          S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bonnie
            wrote on last edited by Bonnie
            #5

            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.

            Ramkumar MohanR 1 Reply Last reply
            1
            • B Bonnie

              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.

              Ramkumar MohanR Offline
              Ramkumar MohanR Offline
              Ramkumar Mohan
              wrote on last edited by
              #6

              @Bonnie

              Now , working fine Thank you...

              1 Reply Last reply
              0
              • Ramkumar MohanR Ramkumar Mohan

                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:-

                bar.JPG

                Ramkumar MohanR Offline
                Ramkumar MohanR Offline
                Ramkumar Mohan
                wrote on last edited by
                #7

                @Ramkumar-Mohan
                @JonB
                How to save only the scene in graphics view. actual scene width and scene height.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved