Unsolved How inputMethodEvent work?
-
I create graphics editor. My application has View, Scene and QGraphicsTextItem. View has Qt::WA_InputMethodEnabled attribute set. I overriden inputMethodEvent in view:
void WorkSpace::inputMethodEvent(QInputMethodEvent* event) { qDebug() << "WorksSpace inputMethodEvent"; QGraphicsView::inputMethodEvent(event); }
When I press some buttons on keyboard, the method does not invoke, as I expected. Futhermore, event does not propagade to scene and focused item. How inputMethodEvent work and how to make it work correctly?
-
Hi
Why not use
void QGraphicsView::keyPressEvent(QKeyEvent *event)
?I never used inputMethodEvent and its related classes and only seen it used for an onscreen keyboard implementation
so I wonder what you try to do? -
Yeah, I currently use keyPressEvent but I though inputMethodEvent would be better soulution. Has Qt some class for key processing and create string? I need to create string in my QGraphicsTexEdit, but I don't wan't to process every key for example backspace etc.
-
Hi
Have a look at the Diagram example
https://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
(its available directly in Creator)It uses
setTextInteractionFlags(Qt::TextEditorInteraction);
to allow easy textinput with support for delete / backspace etc.Maybe that is enough for your use case ?