Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions

How to create a shortcut for spacebar key without using keypressevent?



  • Hi,
    I want to create a shortcut for spacebar key in my qtapplication, I tried following code,

    @QShortcut *VKey_SpaceBar = new QShortcut (QKeySequence (tr("space")), ui->chkAll );

     QObject :: connect (VKey_SpaceBar, SIGNAL(activated()), ui->chkAll, SLOT(click()));@
    

    But, nothing happen, whats wrong in my code.



  • Try simply:

    @QShortcut spacebarShortdcur(QKeySequence(Qt::Key_Space), this, SLOT(calcDirectorySize()), 0, Qt::WidgetWithChildrenShortcut);@


Log in to reply