Hello,
In my plugin, I'd like to use the space bar to invoke an action (ex: change the state of a toolButton in plugin). Is it possible to do that? and what if I use other shortcuts as "CTRL or ALT"?
Thank you in advance!
use space bar as shortcut
Re: use space bar as shortcut
I believe you 'just' need to use the QShortcut object?
Daniel, CloudCompare admin
Re: use space bar as shortcut
Yes indeed.
But I've tried to set up QShortcut in my plugin by many ways, but nothing happens to the shortcut key.
The codes are like this:
QShortcut shortcut_pause = new QShortcut(QKeySequence(Qt::Key_F2), this);
connect(shortcut_pause, SIGNAL(activated()), this, SLOT(onShortcutTriggered()));
Then I found another post: http://www.cloudcompare.org/forum/viewt ... cut#p20715
So, as you said in the post, it's not possible to define custom shortcuts, in 'mainwindow' I suppose? Is it the reason why QShortcut didn't work in my plugin? or maybe there is something wrong somewhere in my program?
To precise: I've placed a break point in the beginning of the slot. But the program never goes into the slot when I press the key. I've also tried other keys, same problem.
But I've tried to set up QShortcut in my plugin by many ways, but nothing happens to the shortcut key.
The codes are like this:
QShortcut shortcut_pause = new QShortcut(QKeySequence(Qt::Key_F2), this);
connect(shortcut_pause, SIGNAL(activated()), this, SLOT(onShortcutTriggered()));
Then I found another post: http://www.cloudcompare.org/forum/viewt ... cut#p20715
So, as you said in the post, it's not possible to define custom shortcuts, in 'mainwindow' I suppose? Is it the reason why QShortcut didn't work in my plugin? or maybe there is something wrong somewhere in my program?
To precise: I've placed a break point in the beginning of the slot. But the program never goes into the slot when I press the key. I've also tried other keys, same problem.
Re: use space bar as shortcut
I believe we were referring to user-defined shortcuts in this post.
In your case, I believe it's more a problem of context/focus. Do you add your shortcut to a dialog? Or is the user interacting with the 3D view? (because in this case, it's the 3D view that will process the shortcuts). You normally have to install a custom event filter if you want to catch the shortcuts (or other events).
In your case, I believe it's more a problem of context/focus. Do you add your shortcut to a dialog? Or is the user interacting with the 3D view? (because in this case, it's the 3D view that will process the shortcuts). You normally have to install a custom event filter if you want to catch the shortcuts (or other events).
Daniel, CloudCompare admin