How to use crtl key to make work on my widget.



  • how to use crtl key to make work on my widget.
    I want when I press the ctrl + 6 s such an action executes on my widget and the action ceases when I press the button again ctrl 6
    here is my code
    @
    QObject::connect(QKeySequence ("Ctrl + 5"), SIGNAL(clicked()), this, SLOT(popp()));
    popp()
    {
    }@

    [Edit: Added @ tags -- mlong]



  • @QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+6"), parent);
    QObject::connect(shortcut, SIGNAL(activated()), receiver, SLOT(yourSlotHere());@



  • thank you very much for your help,
    I want when I press the ctrl + 6 s such an action executes on my widget and the action ceases when I press the button again ctrl 6

    my slot have boolean as argument and I want when I press ctrl6 the first time to execute my slot with true as argument and when I press ctrl 6 again to put my slot argument on on. I try this

    QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+6"), parent);
    QObject::connect(shortcut, SIGNAL(activated(bool)), receiver, SLOT(yourSlotHere(bool));
    

    but it not work,
    i am new in qt


Log in to reply
 

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