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. How to pop up a window for searching when press any key for a char?
Forum Updated to NodeBB v4.3 + New Features

How to pop up a window for searching when press any key for a char?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 182 Views
  • 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    The main window has many child controls, any key for a char (e.g. a letter or a number) can pop up a search window even the focus is on a child widget, with some exceptions (e.g. when the focus is on a text editor, the text editor should work normally instead of poping up the search window).
    How to implement this?

    Problem

    When focus is on a button, keyPressEvent event in the main windows is called, it is as expected.
    But when focus is on a QTreeView derived class, keyPressEvent event in the main window is NOT called, it is not as expected.

    JonBJ 1 Reply Last reply
    0
    • jronaldJ jronald

      The main window has many child controls, any key for a char (e.g. a letter or a number) can pop up a search window even the focus is on a child widget, with some exceptions (e.g. when the focus is on a text editor, the text editor should work normally instead of poping up the search window).
      How to implement this?

      Problem

      When focus is on a button, keyPressEvent event in the main windows is called, it is as expected.
      But when focus is on a QTreeView derived class, keyPressEvent event in the main window is NOT called, it is not as expected.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @jronald
      QTreeView presumably accepts key events just as text edit widget does.

      Have a look at installing an eventFilter() on your QMainWindow like the example there.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved