PDA

View Full Version : QTextEdit Cursor



chris_helloworld
30th September 2010, 11:34
Hi,
Is there anyway to ensure the cursor continues to be shown in a QTextEdit when a menu, (or right click popup menu), is shown ?

Cheers in advance.
Chris.

hasnain
30th September 2010, 12:22
when menu popup focus from text edit shifts to menu.
Use
widget->setfocus;

chris_helloworld
30th September 2010, 12:57
Thanks, I'll give it a go.

chris_helloworld
4th October 2010, 14:13
Simply calling setFocus on my QTextEdit after showing the popup menu didnt work, and also prevented switching focus to other controls as the QTextEdit always took it back again.

Answering my own original question, the solution I found was to effectively filter focusOutEvents, eg,



void MyTextEdit::focusOutEvent(QFocusEvent *event)
{
Qt::FocusReason r = event->reason();
if ((r == Qt::PopupFocusReason) ||
(r == Qt::MenuBarFocusReason)) {
} else {
QTextEdit::focusOutEvent(event);
}
}


Can anyone see any fault in doing this ?
Also, it leaves the cursor blinking. Is there any way to turn it hard on - ie, not blinking ?

Cheers,
Chris.

yao
18th November 2019, 03:09
the cursor is still blinking, but the textedit do not receive any keyboard event