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. [SOLVED] QListView and QShortcut - randomly works or not
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QListView and QShortcut - randomly works or not

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 685 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.
  • M Offline
    M Offline
    mkolenda
    wrote on last edited by mkolenda
    #1

    I have strange problem with QListView and QShortcuts.
    I've made it typically

    QShortcut* sh_esc = new QShortcut(QKeySequence(Qt::Key_Escape), listView, SLOT(clearSelection()));
    QShortcut* sh_ctrlshifta = new QShortcut(QKeySequence("Ctrl+Shift+a"), listView, SLOT(clearSelection()));
    

    It is randomly working or not depending on the build. I have been looking at this for over hour until i have realized that. Its like all of the created shortcuts for this widget work or no one.
    It have nothing to do with specified keys. I can put absolutely everything there and it isn't working.

    ## EDIT ##
    This actually seems to work:

    new QShortcut(QKeySequence(Qt::Key_Escape), listView, SLOT(clearSelection()), SLOT(clearSelection()), Qt::WidgetShortcut);
        new QShortcut(QKeySequence("Ctrl+Shift+a"), listView, SLOT(clearSelection()), SLOT(clearSelection()), Qt::WidgetShortcut);
    

    When it wasn't set to Qt::WidgetShortcut the keys have been handled by listView parents and that stopped them from working.

    1 Reply Last reply
    1

    • Login

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