what does ui->textEdit_35->grabKeyboard(); do ?
-
I am looking for a real live example using grabKeyboard();
C/C++ preferred -
I am looking for a real live example using grabKeyboard();
C/C++ preferred@AnneRanch what does ui->textEdit_35->grabKeyboard(); do ?
According to the documentation:
This widget receives all keyboard events until releaseKeyboard() is called; other widgets get no keyboard events at all. Mouse events are not affected. Use grabMouse() if you want to grab that.
-
Hi
ui->textEdit_35->grabKeyboard()will tell Qt that all keyboards should go to the widget that calls it. Even if the focus is changed so keyboard input will no longer follow focus but stay on the widget.
To go back to normal, one has to call releaseKeyboard()
to use use it simply call
widget->grabKeyboard();
and then later to release it, call
widget->releaseKeyboard();Its not so often used outside of game like navigation where all keys should go to the controller.
-
Hi
ui->textEdit_35->grabKeyboard()will tell Qt that all keyboards should go to the widget that calls it. Even if the focus is changed so keyboard input will no longer follow focus but stay on the widget.
To go back to normal, one has to call releaseKeyboard()
to use use it simply call
widget->grabKeyboard();
and then later to release it, call
widget->releaseKeyboard();Its not so often used outside of game like navigation where all keys should go to the controller.
@mrjj So in not so techie words - if my mouse is positioned in QEdiText widget I can type in and get "textChanged " SIGNAL.
It is not that easy, but I can process the "changing text".So what is the difference in using grab keyboard ?
( I did ask for an example code ...)
-
@mrjj So in not so techie words - if my mouse is positioned in QEdiText widget I can type in and get "textChanged " SIGNAL.
It is not that easy, but I can process the "changing text".So what is the difference in using grab keyboard ?
( I did ask for an example code ...)
@AnneRanch
If you use grabkeyboard on a widget then all keys go to that one, even if you click another widget and start typing.
its hard to give code example as its really just is
widget->grabKeyboard();