From 77be493e45f8d8abf6e9c7432c328e80121d7bc9 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Fri, 17 Jun 2011 09:26:53 +0000 Subject: [PATCH] Qt: fixed keyPressEvent (ticket #803) --- modules/highgui/CMakeLists.txt | 2 +- modules/highgui/src/window_QT.cpp | 16 ++++++---------- modules/highgui/src/window_QT.h | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index a1469aa93a..ff65a71352 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -110,7 +110,7 @@ if (HAVE_QT) SET(_MOC_HEADERS src/window_QT.h ) QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) - set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES}) + set(HIGHGUI_LIBRARIES ${HIGHGUI_LIBRARIES} ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY}) set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES} ) endif() diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 91e6288d79..d97928c505 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -1869,18 +1869,14 @@ void CvWindow::keyPressEvent(QKeyEvent *event) { //see http://doc.trolltech.com/4.6/qt.html#Key-enum int key = event->key(); - bool goodKey = false; + //bool goodKey = false; + bool goodKey = true; - if (key>=20 && key<=255 ) + Qt::Key qtkey = static_cast(key); + char asciiCode = QTest::keyToAscii(qtkey); + if(asciiCode != 0) { - key = (int)event->text().toLocal8Bit().at(0); - goodKey = true; - } - - if (key == Qt::Key_Escape) - { - key = 27; - goodKey = true; + key = static_cast(asciiCode); } //control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index 80de075c48..282bb24d3d 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -79,6 +79,7 @@ #include #include #include +#include //start private enum enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1};