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. [PLEASE HELP] how to make a barcode receiver?
QtWS25 Last Chance

[PLEASE HELP] how to make a barcode receiver?

Scheduled Pinned Locked Moved Solved General and Desktop
57 Posts 9 Posters 13.2k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on 16 Aug 2018, 23:50 last edited by
    #22

    @Pablo-J-Rogina thanks for the warning
    @mrjj take a look here i think you faced this type of problems
    https://forum.qt.io/topic/71310/reading-barcode-from-barcode-scanner

    M P 2 Replies Last reply 17 Aug 2018, 06:27
    0
    • ? A Former User
      16 Aug 2018, 23:50

      @Pablo-J-Rogina thanks for the warning
      @mrjj take a look here i think you faced this type of problems
      https://forum.qt.io/topic/71310/reading-barcode-from-barcode-scanner

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 17 Aug 2018, 06:27 last edited by mrjj
      #23

      @davidlabib

      Yes, that very normal issues when using a
      scanner in HID mode so it acts like a keyboard.

      I usually put a button next to input that says scan and it popup dialog
      to do the scanning in.

      There is no easy solution to what you try. as unless NOTHING else can have focus. ( you can disable focus for buttons) then user might switch to other edit fields.

      Often scanner input is terminated with \n\r or similar- check the documentation
      for the scanner.

      1 Reply Last reply
      3
      • ? A Former User
        16 Aug 2018, 23:50

        @Pablo-J-Rogina thanks for the warning
        @mrjj take a look here i think you faced this type of problems
        https://forum.qt.io/topic/71310/reading-barcode-from-barcode-scanner

        P Offline
        P Offline
        Pablo J. Rogina
        wrote on 17 Aug 2018, 13:59 last edited by
        #24

        @davidlabib I did some grocery shopping yesterday, and looking at the point of sale software the clerk used when I checked out, and also thinking about the shopping cart and checkout process in websites, I wonder why do you need this "always on" scanning phase?

        I mean, maybe you're overcomplicating your requirements. Do you really have such use case from an actual user/customer of your application?

        While checking out most of the software overthere that I remember have some steps/phases:

        1. Initial data (optional)
        2. 1-N items scanning (using barcode reader!!) so focus is there for just one widget (a list where scanned items are added, or a line edit where you click a "Add" button, whatever)
        3. When you are ready (by self-checkout or a clerk helping you) a "Proceeed to checkout" button move to next phase, i.e. Delivery information or just Payment (at this point if credit card is read, again focus is only for reading the credit card data)
        4. "Finish" button to print receipt and move into next customer...

        Is your use case completely different from this scenario? if so, why!?

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2
        • ? Offline
          ? Offline
          A Former User
          wrote on 18 Aug 2018, 00:22 last edited by
          #25

          the only payment method is cash only (for now), so we can skip 3

          It's not very require to make focus when the barcode input something but i thought that it will be a good extra feature in the application

          M R 2 Replies Last reply 18 Aug 2018, 09:40
          0
          • ? A Former User
            18 Aug 2018, 00:22

            the only payment method is cash only (for now), so we can skip 3

            It's not very require to make focus when the barcode input something but i thought that it will be a good extra feature in the application

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 18 Aug 2018, 09:40 last edited by
            #26

            @davidlabib
            Hi
            The complication of trying to guess if its user typing or scanner input
            can be complicated. While often a scan is terminated with same
            symbols, you first know later if scan or keypress and hence
            makes it complicated to handle.

            So its actually complicated to make work flawless and hence a
            straight way of saying for user. "I want to scan" is often preferred.
            As it avoid confusing and guessing.

            1 Reply Last reply
            0
            • ? A Former User
              18 Aug 2018, 00:22

              the only payment method is cash only (for now), so we can skip 3

              It's not very require to make focus when the barcode input something but i thought that it will be a good extra feature in the application

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 18 Aug 2018, 19:38 last edited by raven-worx
              #27

              @davidlabib
              just a note:
              Some barcode scanners have different modes. One mode is "keyboard" mode (like you are using it now) and another can be via the serial interface. The later would let you use QtSerialPort module to receive the scanned code in plain text.
              Those modes can be switched by scanning a special barcode. Take a look at the scanners manual.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              ? 1 Reply Last reply 19 Aug 2018, 12:53
              4
              • R raven-worx
                18 Aug 2018, 19:38

                @davidlabib
                just a note:
                Some barcode scanners have different modes. One mode is "keyboard" mode (like you are using it now) and another can be via the serial interface. The later would let you use QtSerialPort module to receive the scanned code in plain text.
                Those modes can be switched by scanning a special barcode. Take a look at the scanners manual.

                ? Offline
                ? Offline
                A Former User
                wrote on 19 Aug 2018, 12:53 last edited by
                #28

                @raven-worx
                0_1534682994843_f52d64be-c499-4ed8-8c2d-61bd38a1de84-image.png
                0_1534683017626_314576f9-6b75-42fd-b9a7-8124961e7757-image.png
                0_1534683048600_4b9a11df-1307-42af-9058-f90b71a6a88b-image.png
                0_1534683072140_89cd40a7-8a36-49d8-92ab-78edd63f4b99-image.png
                0_1534683090490_c9b50133-170b-49a0-8fea-138ae9c73956-image.png
                0_1534683117128_9f977db8-5b6e-40e8-8f77-80814053f964-image.png
                can you help me on setting the right mod and use QtSerialPort

                J R 2 Replies Last reply 21 Aug 2018, 02:40
                0
                • ? A Former User
                  19 Aug 2018, 12:53

                  @raven-worx
                  0_1534682994843_f52d64be-c499-4ed8-8c2d-61bd38a1de84-image.png
                  0_1534683017626_314576f9-6b75-42fd-b9a7-8124961e7757-image.png
                  0_1534683048600_4b9a11df-1307-42af-9058-f90b71a6a88b-image.png
                  0_1534683072140_89cd40a7-8a36-49d8-92ab-78edd63f4b99-image.png
                  0_1534683090490_c9b50133-170b-49a0-8fea-138ae9c73956-image.png
                  0_1534683117128_9f977db8-5b6e-40e8-8f77-80814053f964-image.png
                  can you help me on setting the right mod and use QtSerialPort

                  J Offline
                  J Offline
                  JKSH
                  Moderators
                  wrote on 21 Aug 2018, 02:40 last edited by
                  #29

                  @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                  can you help me on setting the right mod and use QtSerialPort

                  If you want to use Qt Serial Port, choose the RS-232 option. You will also need to connect the barcode scanner to a serial port on your computer.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  ? 1 Reply Last reply 21 Aug 2018, 23:38
                  2
                  • ? A Former User
                    19 Aug 2018, 12:53

                    @raven-worx
                    0_1534682994843_f52d64be-c499-4ed8-8c2d-61bd38a1de84-image.png
                    0_1534683017626_314576f9-6b75-42fd-b9a7-8124961e7757-image.png
                    0_1534683048600_4b9a11df-1307-42af-9058-f90b71a6a88b-image.png
                    0_1534683072140_89cd40a7-8a36-49d8-92ab-78edd63f4b99-image.png
                    0_1534683090490_c9b50133-170b-49a0-8fea-138ae9c73956-image.png
                    0_1534683117128_9f977db8-5b6e-40e8-8f77-80814053f964-image.png
                    can you help me on setting the right mod and use QtSerialPort

                    R Offline
                    R Offline
                    raven-worx
                    Moderators
                    wrote on 21 Aug 2018, 06:47 last edited by raven-worx
                    #30

                    @davidlabib
                    use the very first code (RS232).
                    Then check the COM port of the scanner it is connected to (e.g. on Windows in the Device Manager).

                    in your .pro file add QT += serialport

                    QSerialPort example usage:

                    QSerialPort* port = new QSerialPort( this );
                    port->setBaudRate( QSerialPort::Baud115200 ); // possible something else, also check the manual
                    port->setPort( QPortInfo("COM4") ); // COM port - check Device Manager for connected port
                    if( port->open(QSerialPort::ReadOnly) )
                    {
                            connect(port, &QSerialPort::readyRead, this, [port]() {
                                  if( !port->bytesAvailable() )
                                       return;
                                  const QByteArray scannedData = port->readAll();
                                  // ...
                            });
                    }
                    else
                    {
                        // check port->error()
                    }
                    

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    ? 1 Reply Last reply 22 Aug 2018, 14:29
                    5
                    • J JKSH
                      21 Aug 2018, 02:40

                      @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                      can you help me on setting the right mod and use QtSerialPort

                      If you want to use Qt Serial Port, choose the RS-232 option. You will also need to connect the barcode scanner to a serial port on your computer.

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on 21 Aug 2018, 23:38 last edited by
                      #31

                      @JKSH is it must came from serial port not usb?

                      J 1 Reply Last reply 21 Aug 2018, 23:57
                      0
                      • ? A Former User
                        21 Aug 2018, 23:38

                        @JKSH is it must came from serial port not usb?

                        J Offline
                        J Offline
                        JKSH
                        Moderators
                        wrote on 21 Aug 2018, 23:57 last edited by
                        #32

                        @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                        is it must came from serial port not usb?

                        Qt Serial Port works with serial ports. A USB port is not a serial port.

                        If your computer doesn't have a serial port, you can use a USB-to-serial converter.

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        M R 2 Replies Last reply 22 Aug 2018, 06:24
                        4
                        • J JKSH
                          21 Aug 2018, 23:57

                          @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                          is it must came from serial port not usb?

                          Qt Serial Port works with serial ports. A USB port is not a serial port.

                          If your computer doesn't have a serial port, you can use a USB-to-serial converter.

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 22 Aug 2018, 06:24 last edited by
                          #33

                          @JKSH
                          Hi
                          this mode, i wonder if
                          alt text

                          does not install a virtual comport and allows to use usb connection much like
                          serial over USB converter. just without the converter.

                          What do you think ? ( purely guessing here)

                          1 Reply Last reply
                          3
                          • J JKSH
                            21 Aug 2018, 23:57

                            @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                            is it must came from serial port not usb?

                            Qt Serial Port works with serial ports. A USB port is not a serial port.

                            If your computer doesn't have a serial port, you can use a USB-to-serial converter.

                            R Offline
                            R Offline
                            raven-worx
                            Moderators
                            wrote on 22 Aug 2018, 06:51 last edited by
                            #34

                            @JKSH said in [PLEASE HELP] how to make a barcode receiver?:

                            Qt Serial Port works with serial ports. A USB port is not a serial port.

                            thats not true. Of course QtSerialPort works with USB.
                            USB = Universal Serial Bus

                            The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

                            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                            If you have a question please use the forum so others can benefit from the solution in the future

                            K 1 Reply Last reply 22 Aug 2018, 21:13
                            1
                            • R raven-worx
                              21 Aug 2018, 06:47

                              @davidlabib
                              use the very first code (RS232).
                              Then check the COM port of the scanner it is connected to (e.g. on Windows in the Device Manager).

                              in your .pro file add QT += serialport

                              QSerialPort example usage:

                              QSerialPort* port = new QSerialPort( this );
                              port->setBaudRate( QSerialPort::Baud115200 ); // possible something else, also check the manual
                              port->setPort( QPortInfo("COM4") ); // COM port - check Device Manager for connected port
                              if( port->open(QSerialPort::ReadOnly) )
                              {
                                      connect(port, &QSerialPort::readyRead, this, [port]() {
                                            if( !port->bytesAvailable() )
                                                 return;
                                            const QByteArray scannedData = port->readAll();
                                            // ...
                                      });
                              }
                              else
                              {
                                  // check port->error()
                              }
                              
                              ? Offline
                              ? Offline
                              A Former User
                              wrote on 22 Aug 2018, 14:29 last edited by
                              #35

                              @raven-worx
                              0_1534947972491_3255bdcc-2942-41cb-986a-e4f1bb6adf9c-image.png
                              I'm using ubuntu now

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 22 Aug 2018, 20:00 last edited by
                                #36

                                Hi,

                                It's QSerialPortInfo.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                1
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on 22 Aug 2018, 20:43 last edited by
                                  #37

                                  0_1534969744372_9c1d0188-4bd4-47a2-9e26-5799df5452cc-image.png

                                  i dosn't do any thing it always execute "else"
                                  QSerialPort::SerialPortError(DeviceNotFoundError)

                                  J 1 Reply Last reply 22 Aug 2018, 23:55
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 22 Aug 2018, 20:53 last edited by
                                    #38

                                    And what is the error ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • R raven-worx
                                      22 Aug 2018, 06:51

                                      @JKSH said in [PLEASE HELP] how to make a barcode receiver?:

                                      Qt Serial Port works with serial ports. A USB port is not a serial port.

                                      thats not true. Of course QtSerialPort works with USB.
                                      USB = Universal Serial Bus

                                      The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

                                      K Offline
                                      K Offline
                                      kuzulis
                                      Qt Champions 2020
                                      wrote on 22 Aug 2018, 21:13 last edited by
                                      #39

                                      @raven-worx said in [PLEASE HELP] how to make a barcode receiver?:

                                      thats not true. Of course QtSerialPort works with USB.
                                      USB = Universal Serial Bus

                                      What? QtSerialPort works only with serial ports. It has nothing common with USB... Please don't confuse peoples. ;)

                                      1 Reply Last reply
                                      2
                                      • ? A Former User
                                        22 Aug 2018, 20:43

                                        0_1534969744372_9c1d0188-4bd4-47a2-9e26-5799df5452cc-image.png

                                        i dosn't do any thing it always execute "else"
                                        QSerialPort::SerialPortError(DeviceNotFoundError)

                                        J Offline
                                        J Offline
                                        JKSH
                                        Moderators
                                        wrote on 22 Aug 2018, 23:55 last edited by JKSH
                                        #40

                                        @davidlabib said in [PLEASE HELP] how to make a barcode receiver?:

                                        QSerialPort::SerialPortError(DeviceNotFoundError)

                                        Well, that means your program can't find a port called COM4. Read the comments in @raven-worx's code and think about what they are asking you to do.

                                        What is the name of the port that your scanner is connected to? https://www.cyberciti.biz/faq/find-out-linux-serial-ports-with-setserial/

                                        @raven-worx said in [PLEASE HELP] how to make a barcode receiver?:

                                        The code above i've posted definitively works with a USB Barcode scanner and i used it myself already.

                                        My apologies; I didn't read the codes or think of the scenario that @mrjj highlighted in his last post.

                                        If the barcode scanner implements RS232-over-USB, then you're right -- Qt Serial Port can indeed work with the scanner via the USB port.

                                        QtSerialPort works with USB.
                                        USB = Universal Serial Bus

                                        Even though they both have "serial" in their names, Universal Serial Bus is completely unrelated to old-school serial ports. The term "serial port" usually refers to an RS-232 port: https://en.wikipedia.org/wiki/Serial_port

                                        A USB device can be programmed to emulate serial port comms, but these are the minority. You cannot, for example, use Qt Serial Port to read your USB keyboard.

                                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                                        1 Reply Last reply
                                        2
                                        • ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on 23 Aug 2018, 03:46 last edited by
                                          #41

                                          @JKSH i didn't worked
                                          i tried form com 1 to com 18
                                          non of them worked

                                          J 1 Reply Last reply 23 Aug 2018, 04:01
                                          0

                                          31/57

                                          21 Aug 2018, 23:38

                                          • Login

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