ok, but must I send any connect and what signal must be supported?
ok, but must I send any connect and what signal must be supported?
No signal, you subclass the control and override the keyPressEvent. If you want a signal, you'll need to emit it from that method.
Xandareva (30th December 2009)
I have one question. How can I move cursor to begin of QTextEdit? Why do I want to move cursor? Because if I press Enter, Message will send to server and all is ok, but I have one problem, Cursor has been in second line after pressed Enter ;/ and if I send second message (press Enter), message will send with word of new line. I would cursor will be in first line after pressed enter.
Thanks for reply
Look at moveCursor method.
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Xandareva (30th December 2009)
I don't know what is wrong here:
And I don't know how to does it remake to work properly.Qt Code:
{ if (obj == message) { switch(keyEvent->key()) { case Qt::Key_Enter: case Qt::Key_Return: sendMessage(); break; } return false; } else { } } else { } }To copy to clipboard, switch view to plain text mode
Last edited by Xandareva; 30th December 2009 at 09:44.
If you want to "eat" the key you must return true.
P.S. This is explained in Qt docs (QObject::eventFilter()):
In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
Last edited by faldzip; 30th December 2009 at 09:55.
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Xandareva (30th December 2009)
but now I can't write in this box.
return true in line 10. Only in case you call sendMessage(). In other places you can return QObject::eventFilter(obj, event);
I would like to be a "Guru"
Useful hints (try them before asking):
- Use Qt Assistant
- Search the forum
If you haven't found solution yet then create new topic with smart question.
Xandareva (30th December 2009)
thx! It works.
Bookmarks