No toolbar icon on CV_GUI_EXPANDED, resizeWindow not working when build highgui with QT (Bug #2070)
Description
There are no toolbar icon when I use CV_GUI_EXPANDED.
And even I use CV_GUI_EXPANDED or CV_GUI_Normal, the function cv::resizeWindow just not working, it always show a window with size about 400x350
I just test using a simple code.
Mat image = imread(filename, 1);
string WinName = "Viewer";
namedWindow(WinName, CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
resizeWindow(WinName, 800, 600);
imshow(WinName, image);
Below is my build Information
General configuration for OpenCV 2.4.1 =====================================
Platform:
Host: Linux 2.6.32-41-generic x86_64
CMake: 2.8.0
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/bin/c++ (ver 4.4.3)
C++ flags (Release): -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mssse3 -msse4.1 -msse4.2 -ffunction-sections -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mssse3 -msse4.1 -msse4.2 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
C Compiler: /usr/bin/gcc
C flags (Release): -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mssse3 -msse4.1 -msse4.2 -ffunction-sections -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mssse3 -msse4.1 -msse4.2 -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3
Linker flags (Release):
Linker flags (Debug):
OpenCV modules:
To be built: calib3d contrib core features2d flann gpu highgui imgproc legacy ml nonfree objdetect photo stitching ts video videostab
Disabled: -
Disabled by dependency: -
Unavailable: androidcamera java python
GUI:
QT 4.x: YES (ver 4.6.2 EDITION = OpenSource)
QT OpenGL support: NO
OpenGL support: NO
Media I/O:
ZLib: build (ver 1.2.6)
JPEG: build (ver 62)
PNG: build (ver 1.5.9)
TIFF: build (ver 42)
JPEG 2000: build (ver 1.900.1)
OpenEXR: /usr/local/lib/libImath.so /usr/local/lib/libIlmImf.so /usr/local/lib/libIex.so /usr/local/lib/libHalf.so /usr/local/lib/libIlmThread.so (ver 1.6.1)
Video I/O:
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: NO
codec: NO
format: NO
util: NO
swscale: NO
gentoo-style: NO
GStreamer: NO
OpenNI: NO
OpenNI PrimeSensor Modules: NO
PvAPI: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: YES/YES
Xine: NO
Other third-party libraries:
Use IPP: 7.0 [7.0.205]
at: /opt/intel/ipp
Use TBB: YES (ver 4.0 interface 6003)
Use Eigen: YES (ver 3.0.2)
Python:
Interpreter: /usr/bin/python2.6 (ver 2.6.5)
Tests and samples:
Tests: YES
Performance tests: YES
Examples: YES
Install path: /usr/local
cvconfig.h is in: /home/changlin/OpenCV-2.4.1/build
-----------------------------------------------------------------
Related issues
related to Patch #2178: #2070 improvements | Cancelled |
History
Updated by Changlin Hsieh over 12 years ago
I upload wrong screenshot when crerating issue.
Attach image is correct
- File Screenshot.png added
Updated by Harald Schmidt over 12 years ago
1. --------------------------------
I use CV_GUI_EXPANDED or CV_GUI_Normal, the function cv::resizeWindow just not working, it always show a window with size about 400x350
Apply resize on parent widget - and it works:
// window_qt.cpp Line: 1855
@// window_qt.cpp Line: 1855 void CvWindow::setViewportSize(QSize size) { QWidget* view = myView->getWidget(); int dx = size.width(); int dy = size.height(); view->parentWidget()->resize(dx-7, dy); myView->setSize(size); } // that was the bugfix @
And now a little improvement:
insert following function e.g. behind cv::moveWindow() in window.cpp :
@void cv::adjustWindowPos( const string& winname, int xp, int xwp, int yp, int yhp ) { // Additional function for % setting of windows: // all values in % relative to screen resulution: #ifdef _WIN32 int cx,cy; cx = GetSystemMetrics(SM_CXSCREEN); cy = GetSystemMetrics(SM_CYSCREEN); int x = 0.01 * ( xp * cx ); int y = 0.01 * ( yp * cy ); int neww = 0.01 * (xwp * cx ); int newh = 0.01 * (yhp * cy ); cvMoveWindow( winname.c_str(), x, y ); cvResizeWindow( winname.c_str(),neww, newh ); #else cvAdjustWindowPosQt( winname.c_str(), xp, xwp, yp, yhp ); #endif }@
additional modify WindowQt.cpp:
in case of Linux we do not have GetSystemMetrics
so let it do by Qt, but one more include is nesseary:
@#include <QDesktopWidget> CV_IMPL void cvAdjustWindowPosQt( const char * name, int xp, int xwp, int yp, int yhp ) { int cx,cy; QDesktopWidget* pDeskWid = QApplication::desktop() ; QRect ScreenGeo = pDeskWid->screenGeometry(); // needs #include <QDesktopWidget> cx = ScreenGeo.width(); cy = ScreenGeo.height(); int x = 0.01 * ( xp * cx ); int y = 0.01 * ( yp * cy ); int neww = 0.01 * (xwp * cx ); int newh = 0.01 * (yhp * cy ); cvMoveWindow( name, x, y ); cvResizeWindow( name, neww, newh ); } @
2.---------------------------------
There are no toolbar icon when I use CV_GUI_EXPANDED.
it works well with Windows XP + Windows 7
It was possible to reproduce this bug for me using Ubuntu
To avoid this bug I wrote some code to read the whole configuration of a button bar
from a *.cfg
In this way you have a free order of several contol types
( all QT, so only QT New function in the moment)
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-gui
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4379