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. Catchin Qt::Key_Tab in QLineEdit
Forum Updated to NodeBB v4.3 + New Features

Catchin Qt::Key_Tab in QLineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • D Offline
    D Offline
    drmhkelley
    wrote on last edited by
    #1

    I'd appreciate someone pointing me to, or otherwise providing me with, a more in-depth summary about how Qt handles tab events.

    For background, I have an application in which I'd like to modify normal tabbing behavior in a context-sensitive way. Depending on broader details of the application state, the tab key would do different thing.

    I think I am actually asking a pretty simple question, and if I could understand one specific failure, I think I could finish up from there.

    Specifically, under what circumstances does Qt (or under what circumstance does it not) pass tab events forward for processing by the user?

    I have a widget based on QLineEdit in which I want to intercept tabs to process myself. The widget works just like I want within a basic app I built just for testing the widget. However, in my real application, tab events never get to the QLineEdit widget. In the test app, one important issue was to setFocusPolicy to Qt::ClickFocus. It seemed that if the underlying processing was expecting to use tab events to navigate between widgets, then the tab events are never passed to QLineEdit at all.

    So in the test app (really just a main window with a QGroupBox to hold a couple of the QLineEdit-based widgets) all I had to do was that setFocusPolicy and the tab key presses were then passed to QLineEdit for processing as I wished.

    Unfortunately, in my full-blown app, tab keys never get to QLineEdit. I have tried the same setFocusPolicy trick for (hopefully) all possible widgets, but someone is still intercepting the tab events and not passing them to me.

    What other sorts of things should I be looking for that would prevent that?

    Any pointers much appreciated.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      Since tab is handled by Qt for navigation, most things can eat it from you.
      http://doc.qt.io/qt-5/focus.html

      You could try to override
      virtual bool QApplication::notify(QObject * receiver, QEvent * e)
      and it should be possible to see who gets your tab at any given moment.

      THere is also
      http://doc.qt.io/qt-5/qplaintextedit.html#tabChangesFocus-prop
      But seems not for lineEdit.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drmhkelley
        wrote on last edited by
        #3

        Thanks. Rather disappointing outcome, but at least I now know I wasn't overlooking something simple.

        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