fixed Qt bug

This commit is contained in:
Yannick Verdie 2010-07-30 14:13:20 +00:00
parent 3ffee6aa04
commit 8f8aba9c88
4 changed files with 26 additions and 20 deletions

View File

@ -519,13 +519,15 @@ if (WITH_QT)
add_definitions(-DHAVE_QT)#We need to define te macro this way, using cvconfig.h.cmake does not work
find_package (OpenGL QUIET)
#if (NOT WIN32) #WIN32 always detect OpenGL, so I disabled it.
if (OPENGL_INCLUDE_DIR)
if (NOT WIN32)#on my Windows, OPENGL_FOUND was true but this path was empty
if (QT_QTOPENGL_FOUND AND OPENGL_FOUND)
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
endif()
set(HAVE_QT_OPENGL 1)
add_definitions(-DHAVE_QT_OPENGL)
endif()
endif()
endif()
endif()

View File

@ -72,11 +72,6 @@ enum { CV_STYLE_NORMAL = 0,//QFont::StyleNormal,
};
/* ---------*/
//the first bit is for normal or autoresize
//CV_WINDOW_NORMAL = 0x00000000 and CV_WINDOW_AUTOSIZE = 0x00000001
//the secont bit is for the gui mode (normal or extended)
enum {CV_GUI_EXPANDED = 0x00000000, CV_GUI_NORMAL = 0x00000010};
//for color cvScalar(blue_component, green_component, red\_component[, alpha_component])
//and alpha= 0 <-> 0xFF (not transparent <-> transparent)
CVAPI(CvFont) cvFont_Qt(const char* nameFont, int pointSize CV_DEFAULT(-1), CvScalar color CV_DEFAULT(cvScalarAll(0)), int weight CV_DEFAULT(CV_FONT_NORMAL), int style CV_DEFAULT(CV_STYLE_NORMAL), int spacing CV_DEFAULT(0));
@ -114,13 +109,17 @@ enum
CV_WND_PROP_ASPECTRATIO= 2,//to change/get window's aspectratio property
//
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_NORMAL = 0,//the user can resize the window (no constraint)
CV_WINDOW_AUTOSIZE = 1,//the user cannot resize the window, the size is constrainted by the image displayed
CV_WINDOW_NORMAL = 0x00000000,//the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
CV_WINDOW_AUTOSIZE = 0x00000001,//the user cannot resize the window, the size is constrainted by the image displayed
//
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
//Those flags are only for Qt
CV_GUI_EXPANDED = 0x00000000,//status bar and tool bar
CV_GUI_NORMAL = 0x00000010,//old fashious way
//
//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_FULLSCREEN = 1,//change the window to fullscreen
CV_WINDOW_FREERATIO = 0,//the image expends as much as it can (no ratio constraint)
CV_WINDOW_KEEPRATIO = 1//the ration image is respected.
CV_WINDOW_FREERATIO = 0x00000100,//the image expends as much as it can (no ratio constraint)
CV_WINDOW_KEEPRATIO = 0x00000000//the ration image is respected.
};
/* create window */

View File

@ -394,6 +394,9 @@ CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char* name_w
QString nameQt(name_trackbar);
CvBar* result = NULL;
if (!name_window && global_control_panel)//window name is null and we have a control panel
layout = global_control_panel->myLayout;
if (!layout)
{
QPointer<CvWindow> w = icvFindWindowByName( name_window );
@ -1343,6 +1346,7 @@ CvWindow::CvWindow(QString arg, int arg2)
param_flags = arg2 & 0x0000000F;
param_gui_mode = arg2 & 0x000000F0;
param_ratio_mode = arg2 & 0x00000F00;
setAttribute(Qt::WA_DeleteOnClose);//in other case, does not release memory
setContentsMargins(0,0,0,0);
@ -1360,7 +1364,7 @@ CvWindow::CvWindow(QString arg, int arg2)
#if defined( HAVE_QT_OPENGL )
mode_display = CV_MODE_OPENGL;
#endif
createView(mode_display);
createView(mode_display, param_ratio_mode);
//3: shortcuts and actions
createActions();
@ -1611,10 +1615,10 @@ void CvWindow::createShortcuts()
QObject::connect( vect_QShortcuts[9], SIGNAL( activated ()),this, SLOT( displayPropertiesWin() ));
}
void CvWindow::createView(int mode)
void CvWindow::createView(int mode, int ratio)
{
//mode = CV_MODE_NORMAL or CV_MODE_OPENGL
myview = new ViewPort(this, mode,CV_WINDOW_KEEPRATIO);//parent, mode_display, keep_aspect_ratio
myview = new ViewPort(this, mode,ratio);//parent, mode_display, keep_aspect_ratio
myview->setAlignment(Qt::AlignHCenter);
}
@ -1806,7 +1810,7 @@ void CvWindow::icvSaveTrackbars(QSettings *settings)
ViewPort::ViewPort(CvWindow* arg, int arg2, int arg3)
{
centralWidget = arg,
setParent(centralWidget);
setParent(centralWidget);
mode_display = arg2;
param_keepRatio = arg3;

View File

@ -291,6 +291,7 @@ public:
CvWinProperties* parameters_window ;
int param_flags;
int param_gui_mode;
int param_ratio_mode;
QVector<QAction*> vect_QActions;
@ -307,7 +308,7 @@ private:
void createShortcuts();
void createActions();
void createToolBar();
void createView(int mode);
void createView(int display_mode, int ratio_mode);
void createStatusBar();
void createGlobalLayout();
void createBarLayout();