Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Barcode reader QML/JS
I'm new here, and I'm glad to see there is an active forum community :).
So far, so good with modification, creating new things etc.
I've been asked to see if it would be possible to implement a barcode receiver with those display. Thus, scan a barcode and put the string in a text box, or a list (as long as I can read it, I'll be fine). There is an USB port I can use to connect the barcode reader.
I've been searching for a while for some examples, or some tips on where to start looking to implement this. I've found various subject with "Barcode" as key word, unfortunately, nothing close, I think, to what I'm looking for.
I'm using a Reach technology display G2H2, if it is worth to mention. According to Reach, I would need to develop my own plugin that I could include where I need it.
Any tips, method/component where I should look and try things with that?
Thank you in advance for your answers.
Hi and welcome to devnet,
Usually these barcode readers are seen as keyboard. If yours is one like that then you just need to give focus on your line edit and it will get filled as if you were typing.
If it behaves differently then you have to give more details about it.
Thank you for your reply.
Yes indeed, it should act as a keyboard.
But as a keyboard, it does not get detected by the screen either. Those little screen were not designed to allow those. Therefore, I need to create the plugin myself. That's what they are telling me.
They do not have an immediate solution for me, they will look into it, eventually, I don't know when.
I just need to confirm if it works. And if so, implement it in the software.
Is there a way to listen to the USB port ?
Their plugin concept is not really clear. At which level is it ?
Do keyboard work with that device ?
Indeed. Well I don't really know as I don't even know where to start with that.
They got their own plugin and it looks like : "import com.reachtech.systemplugin 1.0" when I need something from it.
No, keyboard does not work either. I would need to write down a plugin to make it work.
I would check with them for an example or skeleton to get started.
What OS is this device running ?
I asked them about that.
Linux Kernel 3.10.17 with Qt 5.3.2 and QtCreator IDE 3.2.2.
He seemed to say there should be something to change at a lower level. So I guess, it's gonna be on hold for now.
Thanks though :)
KH-219Design last edited by
It seems like "reachtech" is some kind of a special case (which I am not knowledgeable about).
In general, I want to agree with @SGaist that a barcode reader normally "presents itself" (via its driver or a generic driver) to the system as just another connected keyboard that types keyboard keys as input.
As @SGaist said, if the keyboard focus is set onto some editable control/widget, then when a barcode is scanned it should "just work" and you would see characters from the barcode typed into the editable control.
I will add one other slightly different approach that I have taken in a particular QML-based application. In my particular case, there were no editable on-screen widgets onto which to place keyboard focus. However, the requirement still existed that the application "capture" any scanned barcodes and display them.
In that application, I used QObject::installEventFilter to install an event filter on the root window of the QML app. The app only used a barcode scanner (never a QWERTY keyboard), so it was simple to just filter every QKeyEvent (QEvent::KeyPress) and assume it was input from the barcode scanner.
To better explain what I mean by "root window", the initialization looked like this:
QQmlApplicationEngine engine; // ... other code to initialize the engine with main.qml and so forth const QList<QObject*> objs = engine.rootObjects(); MY_ASSERT( objs.size() == 1, "if the app starts creating more than one root window, " "please reevaluate the logic of our global event filter" ); objs[ 0 ]->installEventFilter( POINTER_TO_CUSTOM_QOBJECT_FILTER_HERE );
For QML applications that have zero editable controls, this was a successful alternative in my experience.