Important: Please read the Qt Code of Conduct -

Ctrl+V goes to wrong widget

  • If I set the paste shortcut on my treeview, place the cursor into a custom editor component, and do Ctrl+V - the treeview steals the paste action despite being out of focus.

    How do I go about debugging this? Ctrl+V works fine in the editor component without the shortcut set on the treeview.

  • Moderators

    If you have this shortcut defined by QShortcut or QAction it probably has too wide of a context. The default context for these classes is Qt::WindowShortcut, which means the shortcut triggers if the focus is anywhere in the window. You can change it to Qt::WidgetWithChildrenShortcut to scope it to the treeview alone.

  • @Chris-Kawa said in Ctrl+V goes to wrong widget:


    Nice, that helped, but now right after pasting the focus changes from the treeview to the next input line after it. How can I have the focus stay where it is after a paste?

  • Hiding an unrelated widget was changing the focus. Weird, but I'll work around it. Thanks for your help!

Log in to reply