Make a left/right arrow QShortcut



  • Hello there!

    I'm trying to make 2 QShortcuts, one for the left and one for the right arrow. This is what I do in the constructor of my dialog:
    @
    (void) new QShortcut(Qt::RightArrow, this, SLOT(on_next_clicked()));
    (void) new QShortcut(Qt::LeftArrow, this, SLOT(on_previous_clicked()));
    @
    but to no avail. I think the problem is that these arrows are taken for browsing among the buttons, lineedits etc that the dialog has.
    So, I tried writing the above code before
    @
    ui->setupUi(this);
    @
    but, (unsurprisingly) it didn't work!

    I also tried with
    @
    (void) new QShortcut(Qt::RightButton, this, SLOT(on_next_clicked()));
    (void) new QShortcut(Qt::LeftButton, this, SLOT(on_previous_clicked()));
    @
    but the problem persists!

    Any suggestions?



  • try using Qt::Key_Left/Right instead... maybe they'll work

    P.S. Qt::ArrowType(Qt::<<Left/Right>>Arrow) is not what you think it is... see "this":http://qt-project.org/doc/qt-4.8/qtoolbutton.html#arrowType-prop
    Qt::<<Left/Right>>Button are mouse buttons



  • Thanks!

    Solved!


Log in to reply
 

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