Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.0.0, 5.0.1, 5.0.2
-
None
-
windows ubuntu
-
Change-Id: I6fa02807255d0abf74aa38e94662bbe3d9e642bb
Description
Hi,
The cause of this problem is that the QGraphicsProxyWidget in its event() method dispatch the case that has been handled by the QGraphicsItem::sceneEvent() method.
Here is an example:
#include <QtGui> #include <QtWidgets> class TextEdit : public QTextEdit { public: explicit TextEdit(QWidget *parent = 0) : QTextEdit(parent) { } void inputMethodEvent(QInputMethodEvent *event) { if (event->type() == QEvent::InputMethod) { qDebug() << "inputMethodEvent called..." << event->preeditString() << event->commitString(); } QTextEdit::inputMethodEvent(event); } }; int main(int argc, char **argv) { QApplication app(argc, argv); TextEdit *widget = new TextEdit; QGraphicsScene scene; QGraphicsProxyWidget *proxy = scene.addWidget(widget); QGraphicsView view(&scene); view.show(); return app.exec(); }
I am working around this with the following code:
bool TextWidget::event(QEvent * event){ if(!this->widget()){ return QGraphicsWidget::event(event); } switch(event->type()){ case QEvent::InputMethod: { //inputMethodEvent(static_cast<QInputMethodEvent *>(event)); return false; } default: return QGraphicsProxyWidget::event(event); } }
This bug will append two (Chinese) words to the string when you only typed one.
I am looking forward to you fixing it. Thanks.