-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
QT backend: cv::waitKey() and cv::waitKeyEx() do not capture arrow keys once you click on the image or press TAB #20215
Description
System information (version)
- OpenCV => 4.5.2
- Operating System / Platform => Linux pajos-VirtualBox 5.8.0-53-generic Changed the link to Q&A forum in the docs html-template #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
- Compiler => gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
Detailed description
Hi,
cv::waitKey() and cv::waitKeyEx() do not capture arrow keys once you click on the image or press TAB. The sample code prints pressed key. When you run it, arrow keys are printed as expected, but if you then click on the image inside the window and press those keys again they won't get printed. Same happens when you press TAB. Moreover, first pressing of TAB prints nothing, but subsequent presses do print. Numpad arrow keys are affected as well. Other keys work fine.
This happens only when built with WITH_QT=ON, otherwise it works as expected.
Complete cmake configuration with WITH_QT=ON: cmake_configure_output.txt. Same configuration with with WITH_QT=OFF works fine.
I found similar issue with TAB (but not mouse click) #9901, but it was closed with: "Looks like "QT" UI backend has been enabled in your OpenCV build. TAB can be preserved to switch between "UI elements" in that case." Which is not the case because pressing TAB does not move focus to control buttons on the top.
This is quite problematic as pip's opencv-python gets built with QT backend...
Steps to reproduce
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include <cstdio>
#include <iostream>
using namespace std;
int main( int argc, char** argv )
{
cv::Mat img = cv::Mat::zeros(cv::Size(300, 300), CV_8UC1);
while (true)
{
cv::imshow("win", img);
int key = cv::waitKey(0) & 0xFF;
cout << key << endl;
if (key == 'q') {
break;
}
}
return 0;
}- Press arrow keys; works fine.
- Click with mouse on the image or press TAB.
- Now pressing arrow key does nothing. Other keys work just fine.
Issue submission checklist
- [ x ] I report the issue, it's not a question
- [ x ] I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - [ x ] I updated to latest OpenCV version and the issue is still there
- [ x ] There is reproducer code and related data files: videos, images, onnx, etc