マウスボタンが押されたら、基底クラスが処理するより前に、選択を解除します。
void MyPlainTextEdit::mousePressEvent(QMouseEvent *e) { QTextCursor c = textCursor(); c.setPosition(c.selectionEnd()); setTextCursor(c); QPlainTextEdit::mousePressEvent(e); }
マウスボタンが押されたら、基底クラスが処理するより前に、選択を解除します。
void MyPlainTextEdit::mousePressEvent(QMouseEvent *e) { QTextCursor c = textCursor(); c.setPosition(c.selectionEnd()); setTextCursor(c); QPlainTextEdit::mousePressEvent(e); }