[PLEASE HELP] how to make a barcode receiver?
-
-
[EDITED]
@SGaist Windows 10
@raven-worx ,Yes the barcode scanner submit return/enter
i had created a simple form and put in it a QLineEdit, QButton and Qlable
and created a slot when i press the button it takes the lineedit text and put it in the lable
also created a shortcut for the button when i return
I'm very sorry about the bad English because it's not my mother language. -
So it's basilly seen as a keyboard, correct ?
-
Then you should check with the Windows API if you can target that specific device.
-
@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
i want to make a Qtextbox always waiting for input even if it wasn't the active widget
This is not the original/intended behavior of this widget or any other related widget. The keyboard input is directed to the widget having the focus.
Given that said:
- have you seen any other application working the way you want?
- I'd say you may want to override the keyPressEvent() method in MainWindow class and when you "detect a barcode" given the focus is not on it, you paste the value received to it. See this SO question for a related matter.
-
- you almost understand me yes in this quote
- I'd say you may want to override the keyPressEvent() method in MainWindow class and when you "detect a barcode" given the focus is not on it, you paste the value received to it. See this SO question for a related matter.
-
i know that making a Qtextbox always waiting for input is impossible but it was a phrase describe what i want (something like that) i mean
-
SO question is not what i mean
what i mean exactly is
at any time and under any condition when the barcode scanner hardware detetect any barcaode it will do_something() -
@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
at any time and under any condition when the barcode scanner hardware detetect any barcaode it will do_something()
You've changed the requirements :-)
In this case I'd say you need to change the barcode driver, and work at a lower level than Qt... so the driver code instead of pasting the decoded text/numbers into the keyboard buffer does some kind of notification that your application can trap. But it looks like that work it's out of scope for Qt framework -
@Pablo-J-Rogina
can you send me your number on whatsapp or telegram or any other messenger so we can have a long conversation in private and after we got the solution i will post it in this topic so other can benefits from it -
@davidlabib please continue this way. I'm not sure I have enough spare time to go on privately. Thanks
-
@Pablo-J-Rogina
OK ,I'm developing a shop manager application.
I'm beginner on programing i had learned c++ just for a year or less
and now I'm learning qt lib.
i don't have problems with sqlite but have problems with the barcode
of course i can make a line edit and button when the button got clicked it will search on the database for the barcode and so on
but the problem is what if I selected another line edit and pointed the barcode scanner hardware to a barcode
it will type on the anther line edit not the barcode line edit
so what is your ideas to solve this problem . -
@Pablo-J.-Rogina said in [PLEASE HELP] how to make a barcode receiver?:
at any time and under any condition when the barcode scanner hardware detetect any barcaode it will do_something()
Can't your barcode scanner just write to a string and you then put it in the correct line edit?
-
@davidlabib To put a string into a line edit this line edit does not need to have focus!
Simply:ui->lineEdit_1->setText(someText);
-
@jsulm I think his problem is at a lower level, not just set the "text" for the proper line edit.
Most barcode reader drivers mimic the keyboard, so when they scan something they place the data read like the keyboard, and SO is facing the issue that if focus is with another widget, not the line edit, if a scan is done that data will go there, or as his last example with the button, lost.
-
@Pablo-J.-Rogina said in [PLEASE HELP] how to make a barcode receiver?:
Most barcode reader drivers mimic the keyboard, so when they scan something they place the data read like the keyboard, and SO is facing the issue that if focus is with another widget, not the line edit, if a scan is done that data will go there, or as his last example with the button, lost.
that's exactly what I'm talking about
You completely understand mebut i don't think that it's a lower level problem
i think that making thread always waiting for input 13 digit --any right barcode in the world contain 13 digit-- less than 1 second
if the input was 13 digit and inputted less than a second then it's a barcode and deal with it as a barcode
else what for input again -
@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
always waiting for input 13 digit --any right barcode in the world contain 13 digit
Be careful with this assumption, think of EAN 8 for instance...
Like the UPC code, there is the EAN-13 symbology with 13 digits, and an abbreviated EAN barcode called the EAN-8 with only 8 digits for smaller goods where space is limited.
-
@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 -
@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. -
@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:
- Initial data (optional)
- 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)
- 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)
- "Finish" button to print receipt and move into next customer...
Is your use case completely different from this scenario? if so, why!?