diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 81617114f6..77827f82b7 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -4063,8 +4063,12 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
         dbg << ", ";
         QtDebugUtils::formatQEnum(dbg, static_cast<Qt::Key>(ke->key()));
         QtDebugUtils::formatNonNullQFlags(dbg, ", ", ke->modifiers());
-        if (!ke->text().isEmpty())
+        if (!ke->text().isEmpty()) {
+            QDebugStateSaver saver(dbg);
             dbg << ", text=" << ke->text();
+            dbg.noquote();
+            dbg << ", text=\"" << ke->text() << '"';
+        }
         if (ke->isAutoRepeat())
             dbg << ", autorepeat, count=" << ke->count();
         dbg << ')';
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index da513408db..e0e35aaa1a 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1917,8 +1917,13 @@ void QGuiApplicationPrivate::captureGlobalModifierState(QEvent *e)
 */
 bool QGuiApplication::notify(QObject *object, QEvent *event)
 {
+    bool v = event->type() == QEvent::InputMethod;
+    if (v)
+        qDebug() << __FUNCTION__ << object << event->type();
     if (object->isWindowType()) {
         if (QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event))
+            if (v)
+                qDebug() << __FUNCTION__ << "b1";
             return true; // Platform plugin ate the event
     }
 
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index e37e85e246..e7458de786 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -308,6 +308,7 @@ void QInputMethod::update(Qt::InputMethodQueries queries)
 */
 void QInputMethod::reset()
 {
+    qDebug() << __FUNCTION__ ;
     Q_D(QInputMethod);
     QPlatformInputContext *ic = d->platformInputContext();
     if (ic)
@@ -324,6 +325,7 @@ void QInputMethod::reset()
 */
 void QInputMethod::commit()
 {
+    qDebug(__FUNCTION__);
     Q_D(QInputMethod);
     QPlatformInputContext *ic = d->platformInputContext();
     if (ic)
@@ -348,6 +350,7 @@ void QInputMethod::commit()
 */
 void QInputMethod::invokeAction(Action a, int cursorPosition)
 {
+    qDebug() << __FUNCTION__ << a << cursorPosition;
     Q_D(QInputMethod);
     QPlatformInputContext *ic = d->platformInputContext();
     if (ic)
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 758490ffb7..97bc2f9990 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -412,8 +412,11 @@ static inline QTextFormat standardFormat(StandardFormat format)
 bool QWindowsInputContext::startComposition(HWND hwnd)
 {
     QObject *fo = QGuiApplication::focusObject();
-    if (!fo)
+    qCDebug(lcQpaInputMethods) << __FUNCTION__ << "fo=" << fo << "hwnd=" << hwnd<< "language=" << m_languageId;
+    if (!fo) {
+        qCDebug(lcQpaInputMethods) << __FUNCTION__ << "startComposition no focus bailout";
         return false;
+    }
     // This should always match the object.
     QWindow *window = QGuiApplication::focusWindow();
     if (!window)
@@ -473,6 +476,17 @@ static inline QList<QInputMethodEvent::Attribute>
     return attributes;
 }
 
+QDebug operator<<(QDebug d, const QInputMethodEvent::Attribute &a)
+{
+    QDebugStateSaver saver(d);
+    d.nospace();
+    d << "Attr(type=" << a.type << ", start=" << a.start << ", len=" << a.length;
+    if (a.value.isValid())
+        d << ", val=" << a.value;
+    d << ')';
+    return d;
+}
+
 /*!
     \brief Notify focus object about markup or final text.
 */
@@ -480,13 +494,28 @@ static inline QList<QInputMethodEvent::Attribute>
 bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn)
 {
     const int lParam = int(lParamIn);
-    qCDebug(lcQpaInputMethods) << '>' << __FUNCTION__ << m_compositionContext.focusObject
-        << debugComposition(lParam) << " composing=" << m_compositionContext.isComposing;
-    if (m_compositionContext.focusObject.isNull() || m_compositionContext.hwnd != hwnd || !lParam)
+    const HIMC himc = m_compositionContext.hwnd ? ImmGetContext(m_compositionContext.hwnd) : nullptr;
+    {
+        auto d  = qDebug().noquote().nospace();
+        d  << "\n>" << __FUNCTION__ << ' ' << m_compositionContext.focusObject
+            << "\n    lParamIn=0x" << Qt::hex << lParamIn << Qt::dec  << ' ' << debugComposition(lParam)
+            << " composing=" << m_compositionContext.isComposing << " him=" << himc << " hwnd=" << hwnd
+            << " m_compositionContext.hwnd=" <<  m_compositionContext.hwnd;
+        if (lParam & GCS_COMPSTR)
+            d << " COMPSTR=\"" << getCompositionString(himc, GCS_COMPSTR) << '"';
+        else if (lParam & GCS_RESULTSTR)
+            d << " GCS_RESULTSTR=\"" << getCompositionString(himc, GCS_RESULTSTR) << '"';
+    }
+
+    if (m_compositionContext.focusObject.isNull() || m_compositionContext.hwnd != hwnd || !lParam) {
+        qDebug() << "composition no focus bailout m_compositionContext.hwnd=" << m_compositionContext.hwnd;
         return false;
-    const HIMC himc = ImmGetContext(m_compositionContext.hwnd);
-    if (!himc)
+    }
+
+    if (!himc) {
+        qDebug() << "composition no HIMC bailout";
         return false;
+    }
 
     QScopedPointer<QInputMethodEvent> event;
     if (lParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) {
@@ -500,30 +529,32 @@ bool QWindowsInputContext::composition(HWND hwnd, LPARAM lParamIn)
         getCompositionStringConvertedRange(himc, &selStart, &selLength);
         if ((lParam & CS_INSERTCHAR) && (lParam & CS_NOMOVECARET)) {
             // make Korean work correctly. Hope this is correct for all IMEs
+            qDebug() << "    Korean special case";
             selStart = 0;
             selLength = m_compositionContext.composition.size();
         }
         if (!selLength)
             selStart = 0;
 
-        event.reset(new QInputMethodEvent(m_compositionContext.composition,
-                                          intermediateMarkup(m_compositionContext.position,
-                                                             m_compositionContext.composition.size(),
-                                                             selStart, selLength)));
+        auto ims = intermediateMarkup(m_compositionContext.position, m_compositionContext.composition.size(), selStart, selLength);
+        qDebug() << __FUNCTION__ << " sel=" << selStart << selLength << "pos=" << m_compositionContext.position
+                 << "len=" <<  m_compositionContext.composition.size() << "attrs="  << ims;
+        event.reset(new QInputMethodEvent(m_compositionContext.composition, ims));
     }
     if (event.isNull())
         event.reset(new QInputMethodEvent);
 
     if (lParam & GCS_RESULTSTR) {
         // A fixed result, return the converted string
-        event->setCommitString(getCompositionString(himc, GCS_RESULTSTR));
+        auto tcs = getCompositionString(himc, GCS_RESULTSTR);
+        qDebug().noquote().nospace() << __FUNCTION__ << " setCommitString(\"" << tcs << "\")";
+        event->setCommitString(tcs);
         if (!(lParam & GCS_DELTASTART))
             endContextComposition();
     }
+    qCDebug(lcQpaInputMethods) << '<' << __FUNCTION__ << " sending markup to=" << m_compositionContext.focusObject ;
     const bool result = QCoreApplication::sendEvent(m_compositionContext.focusObject, event.data());
-    qCDebug(lcQpaInputMethods) << '<' << __FUNCTION__ << "sending markup="
-        << event->attributes().size() << " commit=" << event->commitString()
-        << " to " << m_compositionContext.focusObject << " returns " << result;
+    qCDebug(lcQpaInputMethods) << __FUNCTION__  << "                    sending returned" << result;
     update(Qt::ImQueryAll);
     ImmReleaseContext(m_compositionContext.hwnd, himc);
     return result;
@@ -535,15 +566,21 @@ bool QWindowsInputContext::endComposition(HWND hwnd)
     // Googles Pinyin Input Method likes to call endComposition again
     // when we call notifyIME with CPS_CANCEL, so protect ourselves
     // against that.
-    if (m_endCompositionRecursionGuard || m_compositionContext.hwnd != hwnd)
+    if (m_endCompositionRecursionGuard || m_compositionContext.hwnd != hwnd) {
+        qDebug("endComposition rec bailout");
         return false;
-    if (m_compositionContext.focusObject.isNull())
+    }
+    if (m_compositionContext.focusObject.isNull()) {
+        qDebug("endComposition no focus bailout");
         return false;
+    }
 
     // QTBUG-58300: Ignore WM_IME_ENDCOMPOSITION when CTRL is pressed to prevent
     // for example the text being cleared when pressing CTRL+A
+    auto km = QGuiApplication::queryKeyboardModifiers();
     if (m_locale.language() == QLocale::Korean
-        && QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
+        && km.testFlag(Qt::ControlModifier)) {
+        qDebug() << "endComposition Korean CTRL" << km;
         reset();
         return true;
     }
@@ -551,6 +588,7 @@ bool QWindowsInputContext::endComposition(HWND hwnd)
     m_endCompositionRecursionGuard = true;
 
     imeNotifyCancelComposition(m_compositionContext.hwnd);
+    qDebug() << "endComposition sending" << km;
     if (m_compositionContext.isComposing) {
         QInputMethodEvent event;
         QCoreApplication::sendEvent(m_compositionContext.focusObject, &event);
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index e14ad880da..f6e5b5c65c 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -857,6 +857,7 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd,
     // WM_(IME_)CHAR messages already contain the character in question so there is
     // no need to fiddle with our key map. In any other case add this key to the
     // keymap if it is not present yet.
+    qDebug() << __FUNCTION__ << msg;
     if (msg.message != WM_CHAR && msg.message != WM_IME_CHAR)
         updateKeyMap(msg);
 
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index b87d7e09cc..28e4f4a665 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1770,6 +1770,7 @@ QRect QLineEdit::cursorRect() const
  */
 void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
 {
+    qDebug() << __FUNCTION__ << e;
     Q_D(QLineEdit);
 
     if (echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing()) {
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index e95509ae89..7aa18067ac 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -147,6 +147,7 @@ void QWidgetLineControl::paste(QClipboard::Mode clipboardMode)
 */
 void QWidgetLineControl::commitPreedit()
 {
+    qDebug(__FUNCTION__);
 #ifndef QT_NO_IM
     if (!composeMode())
         return;
@@ -174,6 +175,7 @@ void QWidgetLineControl::commitPreedit()
 */
 void QWidgetLineControl::backspace()
 {
+    qDebug(__FUNCTION__);
     int priorState = m_undoState;
     if (hasSelectedText()) {
         removeSelectedText();
@@ -207,6 +209,7 @@ void QWidgetLineControl::backspace()
 */
 void QWidgetLineControl::del()
 {
+    qDebug().noquote().nospace() << __FUNCTION__ ;
     int priorState = m_undoState;
     if (hasSelectedText()) {
         removeSelectedText();
@@ -240,6 +243,7 @@ void QWidgetLineControl::insert(const QString &newText)
 */
 void QWidgetLineControl::clear()
 {
+    qDebug().noquote().nospace() << __FUNCTION__ ;
     int priorState = m_undoState;
     m_selstart = 0;
     m_selend = m_text.length();
@@ -485,6 +489,11 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
     bool cursorPositionChanged = false;
     bool selectionChange = false;
 
+    qDebug().noquote().nospace() << __FUNCTION__ << event->type() << " isGettingInput=" << isGettingInput
+             << " cs=\"" << event->commitString() << "\", preE=\"" << event->preeditString()
+             << "\", replacementLength=" << event->replacementLength()
+             << ", \"" << m_text << '"';
+
     if (isGettingInput) {
         // If any text is being input, remove selected text.
         priorState = m_undoState;
@@ -493,6 +502,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
             m_selstart = 0;
             m_selend = m_text.length();
         }
+        qDebug() << __FUNCTION__ << "remsel1" << m_selstart << m_selend;
         removeSelectedText();
     }
 
@@ -508,9 +518,11 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
     if (event->replacementLength()) {
         m_selstart = m_cursor;
         m_selend = m_selstart + event->replacementLength();
+        qDebug() << __FUNCTION__ << "remsel2";
         removeSelectedText();
     }
     if (!event->commitString().isEmpty()) {
+        qDebug() << __FUNCTION__ << "inserting";
         internalInsert(event->commitString());
         cursorPositionChanged = true;
     } else {
@@ -730,7 +742,10 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e
     An internal function for setting the text of the line control.
 */
 void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edited)
-{
+{    
+    qDebug().noquote().nospace() << __FUNCTION__ << ' ' << pos << ' ' << edited
+                                 << "\"" << m_text << "\" ->  \"" << txt << '"';
+
     cancelPasswordEchoTimer();
     internalDeselect();
     emit resetInputContext();
@@ -827,6 +842,7 @@ void QWidgetLineControl::internalInsert(const QString &s)
             addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1));
             addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1));
         }
+        qDebug() << __FUNCTION__ << m_cursor <<  ms.length() << ms;
         m_text.replace(m_cursor, ms.length(), ms);
         m_cursor += ms.length();
         m_cursor = nextMaskBlank(m_cursor);
@@ -866,6 +882,8 @@ void QWidgetLineControl::internalInsert(const QString &s)
 void QWidgetLineControl::internalDelete(bool wasBackspace)
 {
     if (m_cursor < (int) m_text.length()) {
+        qDebug().noquote().nospace() << __FUNCTION__ << "> " << wasBackspace
+                   << "\"" << m_text << '"';
         cancelPasswordEchoTimer();
         if (hasSelectedText())
             addCommand(Command(SetSelection, m_cursor, u'\0', m_selstart, m_selend));
@@ -882,6 +900,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace)
             m_text.remove(m_cursor, 1);
         }
         m_textDirty = true;
+        qDebug().noquote().nospace() << __FUNCTION__  << "< \"" << m_text << '"';
     }
 }
 
@@ -897,6 +916,7 @@ void QWidgetLineControl::internalDelete(bool wasBackspace)
 void QWidgetLineControl::removeSelectedText()
 {
     if (m_selstart < m_selend && m_selend <= (int) m_text.length()) {
+        qDebug().noquote().nospace() << __FUNCTION__ <<  "> \"" << m_text << '"';
         cancelPasswordEchoTimer();
         separate();
         int i ;
@@ -926,6 +946,7 @@ void QWidgetLineControl::removeSelectedText()
         if (m_cursor > m_selstart)
             m_cursor -= qMin(m_cursor, m_selend) - m_selstart;
         internalDeselect();
+        qDebug().noquote().nospace() << __FUNCTION__ <<  "< \"" << m_text << '"';
         m_textDirty = true;
     }
 }
@@ -1606,6 +1627,7 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke)
 void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
 {
     bool inlineCompletionAccepted = false;
+    qDebug().noquote().nospace() << __FUNCTION__ << event << " \"" << m_text << '"';
 
 #if QT_CONFIG(completer)
     if (m_completer) {
@@ -1650,6 +1672,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
         if (hasAcceptableInput() || fixup()) {
 
             QInputMethod *inputMethod = QGuiApplication::inputMethod();
+            qDebug() << __FUNCTION__ << "calling commit";
             inputMethod->commit();
             QWidget *lineEdit = qobject_cast<QWidget *>(parent());
             if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine))
@@ -1720,12 +1743,14 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
         }
     }
     else if (event == QKeySequence::Cut) {
+        qDebug() << __FUNCTION__ << "cut";
         if (!isReadOnly() && hasSelectedText()) {
             copy();
             del();
         }
     }
     else if (event == QKeySequence::DeleteEndOfLine) {
+        qDebug() << __FUNCTION__ << "DOL";
         if (!isReadOnly()) {
             setSelection(cursor(), end());
             copy();
@@ -1805,22 +1830,26 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
             layoutDirection() == Qt::LeftToRight ? home(1) : end(1);
     }
     else if (event == QKeySequence::Delete) {
+        qDebug() << __FUNCTION__ << "DEL";
         if (!isReadOnly())
             del();
     }
     else if (event == QKeySequence::DeleteEndOfWord) {
+        qDebug() << __FUNCTION__ << "DELW";
         if (!isReadOnly()) {
             cursorWordForward(true);
             del();
         }
     }
     else if (event == QKeySequence::DeleteStartOfWord) {
+        qDebug() << __FUNCTION__ << "DELSW";
         if (!isReadOnly()) {
             cursorWordBackward(true);
             if (hasSelectedText())
                 del();
         }
     } else if (event == QKeySequence::DeleteCompleteLine) {
+        qDebug() << __FUNCTION__ << "DEL_LINE";
         if (!isReadOnly()) {
             setSelection(0, text().size());
 #ifndef QT_NO_CLIPBOARD
@@ -1873,6 +1902,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
             switch (event->key()) {
             case Qt::Key_Backspace:
                 if (!isReadOnly()) {
+                    qDebug() << __FUNCTION__ << "Key_Backspace";
                     backspace();
 #if QT_CONFIG(completer)
                     complete(Qt::Key_Backspace);
