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
 

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