Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How inputMethodEvent work?
Qt 6.11 is out! See what's new in the release blog

How inputMethodEvent work?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 903 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • clostridium_difficileC Offline
    clostridium_difficileC Offline
    clostridium_difficile
    wrote on last edited by clostridium_difficile
    #1

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      1
      • clostridium_difficileC Offline
        clostridium_difficileC Offline
        clostridium_difficile
        wrote on last edited by
        #3

        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.

        mrjjM 1 Reply Last reply
        0
        • clostridium_difficileC clostridium_difficile

          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.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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 ?

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved