Important: Please read the Qt Code of Conduct -

QShortcut on main window works for customised list view in a widget but not a QTextEdit

  • I have a shortcut on the main window. The main window contains a text edit box derived from QTextEdit and a tab widget derived from QTabWidget (in a layout). The tab contains 4 tabs (derived from QWidget). Each tab contains a list view derived from QListView. The list view is inside a QStackedWidget so you can select from the listview, load another widget, do whatever and go back to the listview.

    The shortcut key works in the following situations:

    • application load (window has focus)
    • listview has focus
    • the text edit is removed from the layout (so only the tab widget containing the listview is on main window)

    The shortcut key does not work when text edit has focus

    I have stripped out all the code from my text edit (and even tried substituting it with a QTextEdit) yet the shortcut still does not work. On the other hand if the listview has focus the shortcut key works even though it is several layers away from the main window and has plenty of my own non QListview code in it.

    The text edit needs to be read-only (could probably be a label) so I have made it read-only which means it never gets focus which solves the problem but I would still like to know why I am getting this behaviour - what am I missing? Is there something special for text edits because it is expecting to receive characters?? (the short cut it ctrl+home)

  • Are there any ideas on how this function works?

  • Which function? Do you mean what the shortcut calls? (currently nothing, code is commented out, I determine it has been reached by a breakpoint).

Log in to reply