diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 4b6de71e5..fd7f227ca 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -72,6 +72,7 @@ if(WIN32) #SET(QT_USE_QTXML 1) INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) @@ -94,6 +95,7 @@ if(UNIX) #SET(QT_USE_QTXML 1) INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) @@ -186,6 +188,7 @@ if(APPLE) #SET(QT_USE_QTXML 1) INCLUDE(${QT_USE_FILE}) + SET(_MOC_HEADERS src/window_QT.h) QT4_WRAP_CPP(_MOC_OUTFILES ${_MOC_HEADERS}) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index d89686eb5..113606490 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -55,15 +55,13 @@ QMutex mutexKey; //end declaration - -CV_IMPL int cvChangeMode_QT(const char* name,int prop_value) +void cvChangeMode_QT(const char* name, double prop_value) { //CV_WINDOW_NORMAL or CV_WINDOW_FULLSCREEN - - return 0; + } -CV_IMPL int cvGetMode_QT(const char* name) +double cvGetMode_QT(const char* name) { return 0; @@ -74,9 +72,10 @@ CV_IMPL int cvWaitKey( int arg ) CV_FUNCNAME( "cvWaitKey" ); - __BEGIN__; - int result = -1; + + __BEGIN__; + unsigned long delayms;//in milliseconds if (arg<=0) delayms = ULONG_MAX; @@ -150,13 +149,14 @@ CV_IMPL CvWindow* icvFindWindowByName( const char* arg ) CV_FUNCNAME( "icvFindWindowByName" ); + QPointer window = NULL; + __BEGIN__; if( !arg ) CV_Error( CV_StsNullPtr, "NULL name string" ); QString name(arg); - QPointer window = NULL; QPointer w; foreach (QWidget *widget, QApplication::topLevelWidgets()) { @@ -177,6 +177,8 @@ CV_IMPL CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char CV_FUNCNAME( "icvFindTrackbarByName" ); + QPointer result = NULL; + __BEGIN__; QPointer w = icvFindWindowByName( name_window ); @@ -185,7 +187,6 @@ CV_IMPL CvTrackbar* icvFindTrackbarByName( const char* name_trackbar, const char CV_Error( CV_StsNullPtr, "NULL window handler" ); QString nameQt = QString(name_trackbar); - QPointer result = NULL; QPointer t; //for now, only trackbar are added so the Mutable cast is ok. @@ -394,11 +395,11 @@ CV_IMPL int cvCreateTrackbar( const char* trackbar_name, const char* window_name CV_IMPL int cvGetTrackbarPos( const char* trackbar_name, const char* window_name ) { CV_FUNCNAME( "cvGetTrackbarPos" ); - - __BEGIN__; int result = -1; + __BEGIN__; + QPointer t = icvFindTrackbarByName( trackbar_name, window_name ); if (t) @@ -621,12 +622,15 @@ CvTrackbar::CvTrackbar(CvWindow* arg, QString name, int* value, int count, CvTra //Change style of the Slider - QFile qss(PATH_QSLIDERCSS); - if (qss.open(QFile::ReadOnly)) - { - slider->setStyleSheet(QLatin1String(qss.readAll())); - qss.close(); - } + slider->setStyleSheet(str_Trackbar_css); + + //QFile qss(PATH_QSLIDERCSS); + //if (qss.open(QFile::ReadOnly)) + //{ + //slider->setStyleSheet(QLatin1String(qss.readAll())); + //qss.close(); + //} + //does not work if we change the style with a stylesheet, why ? //slider->setTickPosition(QSlider::TicksBelow); diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index 9e2aa259d..5c7e8d5cf 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -68,7 +68,6 @@ //Macro here #define CV_MODE_NORMAL 0 #define CV_MODE_OPENGL 1 -#define PATH_QSLIDERCSS "../SliderCss.qss" //end macro //Here declare everything @@ -203,3 +202,66 @@ private: private slots: void stopDisplayInfo(); }; + + +//here css for trackbar +/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */ +//#define PATH_QSLIDERCSS ":/qss/window_QT.qss" +static const QString str_Trackbar_css = "QSlider::groove:horizontal {";/* ++ "border: 1px solid #bbb;" ++ "background: white;" ++ "height: 10px;" ++ "border-radius: 4px;" ++ "}"; + + +QSlider::sub-page:horizontal { +background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, +stop: 0 #66e, stop: 1 #bbf); +background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1, +stop: 0 #bbf, stop: 1 #55f); +border: 1px solid #777; +height: 10px; +border-radius: 4px; +} + +QSlider::add-page:horizontal { +background: #fff; +border: 1px solid #777; +height: 10px; +border-radius: 4px; +} + +QSlider::handle:horizontal { +background: qlineargradient(x1:0, y1:0, x2:1, y2:1, +stop:0 #eee, stop:1 #ccc); +border: 1px solid #777; +width: 13px; +margin-top: -2px; +margin-bottom: -2px; +border-radius: 4px; +} + +QSlider::handle:horizontal:hover { +background: qlineargradient(x1:0, y1:0, x2:1, y2:1, +stop:0 #fff, stop:1 #ddd); +border: 1px solid #444; +border-radius: 4px; +} + +QSlider::sub-page:horizontal:disabled { +background: #bbb; +border-color: #999; +} + +QSlider::add-page:horizontal:disabled { +background: #eee; +border-color: #999; +} + +QSlider::handle:horizontal:disabled { +background: #eee; +border: 1px solid #aaa; +border-radius: 4px; +}*/ +