PDA

View Full Version : QAction shortcuts from QLineEdit



discostu
4th March 2007, 06:09
Hi, I have a QLineEdit area where the user types. I also have a bunch of QActions with shortcuts. When the user is typing in the QLineEdit area it triggers QActions due to conflicting shortcut key sequences. Is there a way to disable shortcuts when the QLineEdit area has focus?

Thanks.
Stu

Lykurg
4th March 2007, 13:52
Like Disco STU I like disco music...

You can try following solutions

a) Check in each QAction-slot-function if QLineEdit has the focus and break execution if true

b) Write your own event handler for QFocusEvent. gotFocus(): disable the signals, lostFocus(): enable it again.


Lykurg

wysota
4th March 2007, 14:26
Where did you assign the actions to? Could we see the code?

discostu
4th March 2007, 15:43
Like Disco STU I like disco music...

You can try following solutions

a) Check in each QAction-slot-function if QLineEdit has the focus and break execution if true

b) Write your own event handler for QFocusEvent. gotFocus(): disable the signals, lostFocus(): enable it again.


Lykurg

Thanks, but i don't want the action to be disabled, just the shortcut. It seems that the only way you can disable the shortcut is to set it to empty string. So does this mean that everytime QLineEdit get's focus I have to loop through all my QActions and set their shorcuts to "" ?

btw, I am using fullmetalcoder's qshortcutmanager