summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/qnamespace.qdoc24
-rw-r--r--src/corelib/global/qnamespace.h16
-rw-r--r--src/gui/kernel/qwidget.cpp32
-rw-r--r--src/gui/kernel/qwidget.h5
-rw-r--r--src/gui/kernel/qwidget_p.h2
5 files changed, 78 insertions, 1 deletions
diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc
index 674169e..5ffae83 100644
--- a/doc/src/qnamespace.qdoc
+++ b/doc/src/qnamespace.qdoc
@@ -2392,6 +2392,30 @@
*/
/*!
+ \enum Qt::InputMethodHint
+
+ \value ImhNone No hints.
+ \value ImhHiddenText Characters should be hidden, as is typically used when entering passwords.
+ This is automatically set when setting QLineEdit::echoMode to \c Password.
+ \value ImhNumbersOnly Only number input is allowed.
+ \value ImhUppercaseOnly Only upper case letter input is allowed.
+ \value ImhLowercaseOnly Only lower case letter input is allowed.
+ \value ImhNoAutoUppercase The input method should not try to automatically switch to upper case
+ when a sentence ends.
+ \value ImhPreferNumbers Numbers are preferred (but not required).
+ \value ImhPreferUppercase Upper case letters are preferred (but not required).
+ \value ImhPreferLowercase Lower case letters are preferred (but not required).
+ \value ImhNoPredictiveText Do not use predictive text (i.e. dictionary lookup) while typing.
+ \value ImhDialableCharactersOnly Only characters suitable for phone dialling are allowed.
+
+ \note If several flags ending with \c Only are ORed together, the resulting character set will
+ consist of the union of the specified sets. For instance specifying \c ImhNumbersOnly and
+ \c ImhUppercaseOnly would yield a set consisting of numbers and uppercase letters.
+
+ \sa QWidget::inputMethodHints
+*/
+
+/*!
\enum Qt::InputMethodQuery
\value ImMicroFocus The rectangle covering the area of the input cursor in widget coordinates.
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 7d8b321..1475b2e 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1398,6 +1398,21 @@ public:
ImMaximumTextLength
};
+ enum InputMethodHint {
+ ImhNone = 0x0,
+ ImhHiddenText = 0x1,
+ ImhNumbersOnly = 0x2,
+ ImhUppercaseOnly = 0x4,
+ ImhLowercaseOnly = 0x8,
+ ImhNoAutoUppercase = 0x10,
+ ImhPreferNumbers = 0x20,
+ ImhPreferUppercase = 0x40,
+ ImhPreferLowercase = 0x80,
+ ImhNoPredictiveText = 0x100,
+ ImhDialableCharactersOnly = 0x200
+ };
+ Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)
+
enum ToolButtonStyle {
ToolButtonIconOnly,
ToolButtonTextOnly,
@@ -1559,6 +1574,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::DropActions)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ItemFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints)
typedef bool (*qInternalCallback)(void **);
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 7eaebbb..64aeab5 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -199,6 +199,7 @@ QWidgetPrivate::QWidgetPrivate(int version) :
,needWindowChange(0)
,isGLWidget(0)
#endif
+ ,imHints(Qt::ImhNone)
,polished(0)
, size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
@@ -8457,7 +8458,7 @@ void QWidget::inputMethodEvent(QInputMethodEvent *event)
\a query specifies which property is queried.
- \sa inputMethodEvent(), QInputMethodEvent, QInputContext
+ \sa inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints
*/
QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
{
@@ -8471,6 +8472,35 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
}
}
+/*!
+ \property QWidget::inputMethodHints
+ \brief What input method specific hints the widget has.
+
+ This is only relevant for input widgets. It is used by
+ the input method to retrieve hints as to how the input method
+ should operate. For example, if the Qt::ImhNumbersOnly flag is
+ set, the input method may change its visual components to reflect
+ that only numbers can be entered.
+
+ The effect may vary between input method implementations.
+
+ \since 4.6
+
+ \sa inputMethodQuery(), QInputContext
+*/
+Qt::InputMethodHints QWidget::inputMethodHints() const
+{
+ Q_D(const QWidget);
+ return d->imHints;
+}
+
+void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
+{
+ Q_D(QWidget);
+ d->imHints = hints;
+}
+
+
#ifndef QT_NO_DRAGANDDROP
/*!
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 8ecf758..b92794f 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -212,6 +212,7 @@ class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
#endif
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
public:
enum RenderFlag {
@@ -673,6 +674,10 @@ protected:
virtual void inputMethodEvent(QInputMethodEvent *);
public:
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
+ Qt::InputMethodHints inputMethodHints() const;
+ void setInputMethodHints(Qt::InputMethodHints hints);
+
protected:
void resetInputContext();
protected Q_SLOTS:
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index ec64b6e..2c68338 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -604,6 +604,8 @@ public:
uint isGLWidget : 1;
#endif
+ Qt::InputMethodHints imHints;
+
#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_S60)
#ifdef Q_WS_MAC
void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());