summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2010-12-13 10:29:22 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2010-12-13 14:16:52 (GMT)
commit0af1f5508e165f3b494ab236cb1cdf1b0edcffa5 (patch)
treeade12cabfc854cf57c005bd6229b576d7da6dee0 /tests/auto/qgraphicsview
parent6160f8541e4d7cb66de7680b5fb439fb757c59dd (diff)
downloadQt-0af1f5508e165f3b494ab236cb1cdf1b0edcffa5.zip
Qt-0af1f5508e165f3b494ab236cb1cdf1b0edcffa5.tar.gz
Qt-0af1f5508e165f3b494ab236cb1cdf1b0edcffa5.tar.bz2
Fixes text jitter in QtQuick components when using the virtual keyboard
QGraphicsView::mapFromScene() returns a QRect instead of a QRectF. Thus, we were prematurely rounding the micro focus rectangle coordinates in QGraphicsView::inputMethodQuery(). (The Qt::ImMicroFocus query returns a QRectF from QGraphicsScene, which is the result of querying QDeclarativeTextEdit and mapping it to the scene.) Auto-test included. Reviewed-by: leo Reviewed-by: bnilsen Task-number: QTCOMPONENTS-288 Task-number: QTBUG-16063
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 0a9633f..e1fbaee 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -246,6 +246,7 @@ private slots:
void QTBUG_4151_clipAndIgnore();
void QTBUG_5859_exposedRect();
void QTBUG_7438_cursor();
+ void QTBUG_16063_microFocusRect();
public slots:
void dummySlot() {}
@@ -4450,5 +4451,43 @@ void tst_QGraphicsView::QTBUG_7438_cursor()
#endif
}
+class IMItem : public QGraphicsRectItem
+{
+public:
+ IMItem(QGraphicsItem *parent = 0):
+ QGraphicsRectItem(mf.adjusted(-5, -5, 5, 5), parent)
+ {
+ setFlag(QGraphicsItem::ItemIsFocusable, true);
+ setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ }
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const
+ {
+ return mf;
+ }
+
+ static QRectF mf;
+};
+
+QRectF IMItem::mf(1.5, 1.6, 10, 10);
+
+void tst_QGraphicsView::QTBUG_16063_microFocusRect()
+{
+ QGraphicsScene scene;
+ IMItem *item = new IMItem();
+ scene.addItem(item);
+
+ QGraphicsView view(&scene);
+
+ view.setFixedSize(40, 40);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ scene.setFocusItem(item);
+ view.setFocus();
+ QRectF mfv = view.inputMethodQuery(Qt::ImMicroFocus).toRectF();
+ QCOMPARE(mfv, QRectF(13.5, 13.6, 10, 10));
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"