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. QKeyEvent and child
Forum Updated to NodeBB v4.3 + New Features

QKeyEvent and child

Scheduled Pinned Locked Moved Unsolved General and Desktop
qkeyevent
8 Posts 4 Posters 2.3k Views 1 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.
  • VincentBV Offline
    VincentBV Offline
    VincentB
    wrote on last edited by
    #1

    Hi,

    I'm currently trying to catch events from a bar code reader. The bar code reader works like an USB keyboard (try with evtest under linux and that's ok).
    First, I've simply work on a MainWindow and success to catch all keyboard event from the bar code reader.
    Then, I've added another window to catch these events : I try with a QInputDialog, QDialog and QMainWindow but without success. It seems that Qt misses some keyvent, not all characters are printed in qlineedit.

    Example :

    QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"),
                                                 tr("User name:"), QLineEdit::Normal,
                                                 "test", &ok);
            if (ok && !text.isEmpty())
                qDebug() << Q_FUNC_INFO << text;
    

    qdebug only outputs 9 characters instead of 16.

    How to prevent these missed characters ?

    Thanks

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      What I have understood from your description is that you are able to catch all the keyboard events from from MainWindow. It means that you have class which is inherited from QMainWindow and implemented keyPressEvent(...). If this the case Qt is not missing any event. Not sure what is missing here. If nothing works, we can build our own events based on what is received from BarCode reader and post the events to appropriate objects using the Application::postEvent(..).

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      4
      • VincentBV Offline
        VincentBV Offline
        VincentB
        wrote on last edited by
        #3

        @dheerendra
        What I have understood from your description is that you are able to catch all the keyboard events from from MainWindow. It means that you have class which is inherited from QMainWindow and implemented keyPressEvent(...). If this the case Qt is not missing any event.
        You correctly understood.

        Now, I would like to add an inputdialog where BarCode reader key events are catched and displayed in a LineEdit (for example). But it appears that not all characters are catched. The missing characters nor appears in keyPressEvent of parent neither in child (qinputdialog).

        Could you please advise me on how to proceed step by step to track correctly these events ?

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Peer Schneider
          wrote on last edited by
          #4

          Is it guaranteed that the keyboard events all represent characters which can be displayed? Could it be possible that the keyboard events could represent white spaces or similar things?

          1 Reply Last reply
          0
          • VincentBV Offline
            VincentBV Offline
            VincentB
            wrote on last edited by
            #5

            Hi @Peer-Schneider ,

            Bar code is composed with printable characters (alphanumeric). On the default MainWindow (automatically generated by qtCreator with ui) I catch all characters and then print them in a lineEdit.

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              Since you are catching all the keyboard events, you can create your own QLineEdit object and post those key events to lineEdit object. This is just work-around to check whether lineEdit catching or displaying those values.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              5
              • VincentBV Offline
                VincentBV Offline
                VincentB
                wrote on last edited by
                #7

                @dheerendra , I'll try as soon as possible. Thanks

                Andy314A 1 Reply Last reply
                0
                • VincentBV VincentB

                  @dheerendra , I'll try as soon as possible. Thanks

                  Andy314A Offline
                  Andy314A Offline
                  Andy314
                  wrote on last edited by
                  #8

                  Hi @Vincent,
                  I use a barcode scanner for my app, too. All works without problem for me.
                  Did you try to input the "key events" in a simple text editor of you OS. Which characters compared to the editor are missing in Qt ?

                  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