[PLEASE HELP] how to make a barcode receiver?
-
I'm trying to make a shop manger application and i want to make a barcode receiver .
when I connect my barcode reader and point to a barcode it inserts the barcode numbers and press enter automatically, so i want to make a Qtextbox always waiting for input even if it wasn't the active widget. -
@davidlabib said in [PLEASE HELP] how to make a barcode receiver?:
so i want to make a Qtextbox always waiting for input even if it wasn't the active widget.
what?
-
@raven-worx as you can see
the Qlineedit number 1 is the active which mean if i typed something it will be in this field not 2 or 3 -
@davidlabib
does your barcode scanner really submit a return/enter key press?
I assume it is rather a\r
or\n
character at the end? -
-
[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