Qt: fixed keyPressEvent (ticket #803)

This commit is contained in:
Ilya Lysenkov 2011-06-17 09:26:53 +00:00
parent 83a4a41cde
commit 77be493e45
3 changed files with 8 additions and 11 deletions

View File

@ -110,7 +110,7 @@ if (HAVE_QT)
SET(_MOC_HEADERS src/window_QT.h ) SET(_MOC_HEADERS src/window_QT.h )
QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) 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} ) set(highgui_srcs ${highgui_srcs} src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES} )
endif() endif()

View File

@ -1869,18 +1869,14 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
{ {
//see http://doc.trolltech.com/4.6/qt.html#Key-enum //see http://doc.trolltech.com/4.6/qt.html#Key-enum
int key = event->key(); int key = event->key();
bool goodKey = false; //bool goodKey = false;
bool goodKey = true;
if (key>=20 && key<=255 ) Qt::Key qtkey = static_cast<Qt::Key>(key);
char asciiCode = QTest::keyToAscii(qtkey);
if(asciiCode != 0)
{ {
key = (int)event->text().toLocal8Bit().at(0); key = static_cast<int>(asciiCode);
goodKey = true;
}
if (key == Qt::Key_Escape)
{
key = 27;
goodKey = true;
} }
//control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions //control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions

View File

@ -79,6 +79,7 @@
#include <QRadioButton> #include <QRadioButton>
#include <QButtonGroup> #include <QButtonGroup>
#include <QMenu> #include <QMenu>
#include <QtTest/QTest>
//start private enum //start private enum
enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1}; enum {CV_MODE_NORMAL= 0, CV_MODE_OPENGL = 1};