[SOLVED] QListView and QShortcut - randomly works or not

  • 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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.