From 9ef61d3d1e53d32dc2568cbfb9f8ff5b19cb4ffc Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 27 Aug 2010 14:09:40 +0300 Subject: QLineEdit cursor is shown when asked to be non-visible If QLineEdit is sent a QInputMethodEvent::Cursor event with value zero, widget still shows blinking cursor. This is due to that QLineControl ignores its internal state variable m_hideCursor value. As a fix, m_hideCursor is now considered when drawing the cursor. Additionally, the cursor blinking timer is stopped when cursor is hidden. Task-number: QT-3670 Reviewed-by: axis --- src/gui/widgets/qlinecontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index d027b91..7f0c6c8 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -464,6 +464,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) if (a.type == QInputMethodEvent::Cursor) { m_preeditCursor = a.start; m_hideCursor = !a.length; + if (m_hideCursor) + setCursorBlinkPeriod(0); } else if (a.type == QInputMethodEvent::TextFormat) { QTextCharFormat f = qvariant_cast(a.value).toCharFormat(); if (f.isValid()) { @@ -527,7 +529,7 @@ void QLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &cl int cursor = m_cursor; if (m_preeditCursor != -1) cursor += m_preeditCursor; - if(!m_blinkPeriod || m_blinkStatus) + if (!m_hideCursor && (!m_blinkPeriod || m_blinkStatus)) m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth); } } -- cgit v0.12