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. Keyboard event and text cursor for hiden widget
Forum Updated to NodeBB v4.3 + New Features

Keyboard event and text cursor for hiden widget

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • L Offline
    L Offline
    Lafacce
    wrote on last edited by
    #1

    Hi all,

    I've developped a widget application in QT. For now, I'm compiling for windows and I intend to compile for linux in the future.

    So, my widget always stays hiden and it has an icon menu for configuring. What I need to do now is get data from the keyboard input, manipulate it and then print it into text cursor in current visible window. For example, if the cursor is on browser url, my programm should get keyboard input, manipulate it and print some data into browser url.

    If it was a console, it should get data from stdin and prints something into stdout.

    I've implemented using Keyboard event. Something like [URL="http://www.qtcentre.org/threads/45159-keyPressEvent-not-being-called"]http://www.qtcentre.org/threads/45159-keyPressEvent-not-being-called[/URL]

    The problem is: this only woks if the widget is active, not hiden (as far as I've seen).

    I'm thinking in using this: [URL="http://qt-project.org/doc/qt-4.8/eventsandfilters.html"]http://qt-project.org/doc/qt-4.8/eventsandfilters.html[/URL]. But I want to be sure it will work out.

    For sending data is the "same" problem, the widget is not active, so, how to put data to cursor text? Can I use QTextCursor?

    I've been trying to find out a solution without success.

    Does anybody can help with this issue?

    Thanks a lot.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rolias
      wrote on last edited by
      #2

      Just a thought. Can you change how you're hiding it? For instance in QML (I know you're doing Qt Widgets) if you set the visibility to false, you can't capture events, but if you set the opacity to 0, then the item is effectively hidden but it still responds to events.

      Check out my third course in the trilogy on Qt
      "Integrating Qt Quick with C++"
      http://bit.ly/qtquickcpp
      published by Pluralsight

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Lafacce
        wrote on last edited by
        #3

        Hi, Rolias.

        I've just tried and, unfortunately, I didn't work.

        setVisible(false) -> the keyboard only if the icon menu is visible.

        Opacity = 0 -> the keyboard works, but if the widget is selected. If another window , e.g. web browser, is actived, the keyboard event is not set.

        Thanks for the tip.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Lafacce
          wrote on last edited by
          #4

          Any ideas?

          Well, I've read some links saying to use Windows raw input:

          "Windows raw input":http://www.cplusplus.com/forum/windows/95700/

          "BarcodeScanner":http://nicholas.piasecki.name/blog/2009/02/distinguishing-barcode-scanners-from-the-keyboard-in-winforms/

          For notice, I'm using QT Creator 2.4.1; QT SDK 4.8.1; MSVC 2010 compiler on windows 7.

          Following these links, I'm getting compiling errors for Windows functions.

          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