6565
6666using namespace cv ;
6767
68+ #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
69+ #define Qt_MiddleButton Qt::MiddleButton
70+ inline Qt::Orientation wheelEventOrientation (QWheelEvent *we) {
71+ if (std::abs (we->angleDelta ().x ()) < std::abs (we->angleDelta ().y ()))
72+ return Qt::Vertical;
73+ else
74+ return Qt::Horizontal;
75+ }
76+ inline int wheelEventDelta (QWheelEvent *we) {
77+ if (wheelEventOrientation (we) == Qt::Vertical)
78+ return we->angleDelta ().y ();
79+ else
80+ return we->angleDelta ().x ();
81+ }
82+ inline QPoint wheelEventPos (QWheelEvent *we) {
83+ return we->position ().toPoint ();
84+ }
85+ #else
86+ #define Qt_MiddleButton Qt::MidButton
87+ inline Qt::Orientation wheelEventOrientation (QWheelEvent *we) {
88+ return we->orientation ();
89+ }
90+ inline int wheelEventDelta (QWheelEvent *we) {
91+ return we->delta ();
92+ }
93+ inline QPoint wheelEventPos (QWheelEvent *we) {
94+ return we->pos ();
95+ }
96+
97+ #endif
98+
99+
68100// Static and global first
69101static GuiReceiver *guiMainThread = NULL ;
70102static int parameterSystemC = 1 ;
@@ -1580,7 +1612,9 @@ CvWinProperties::CvWinProperties(QString name_paraWindow, QObject* /*parent*/)
15801612 myLayout->setObjectName (QString::fromUtf8 (" boxLayout" ));
15811613 myLayout->setContentsMargins (0 , 0 , 0 , 0 );
15821614 myLayout->setSpacing (0 );
1615+ #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
15831616 myLayout->setMargin (0 );
1617+ #endif
15841618 myLayout->setSizeConstraint (QLayout::SetFixedSize);
15851619 setLayout (myLayout);
15861620
@@ -1958,7 +1992,9 @@ void CvWindow::createBarLayout()
19581992 myBarLayout->setObjectName (QString::fromUtf8 (" barLayout" ));
19591993 myBarLayout->setContentsMargins (0 , 0 , 0 , 0 );
19601994 myBarLayout->setSpacing (0 );
1995+ #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
19611996 myBarLayout->setMargin (0 );
1997+ #endif
19621998}
19631999
19642000
@@ -1968,7 +2004,9 @@ void CvWindow::createGlobalLayout()
19682004 myGlobalLayout->setObjectName (QString::fromUtf8 (" boxLayout" ));
19692005 myGlobalLayout->setContentsMargins (0 , 0 , 0 , 0 );
19702006 myGlobalLayout->setSpacing (0 );
2007+ #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
19712008 myGlobalLayout->setMargin (0 );
2009+ #endif
19722010 setMinimumSize (1 , 1 );
19732011
19742012 if (param_flags == CV_WINDOW_AUTOSIZE)
@@ -2206,7 +2244,7 @@ void CvWindow::icvLoadControlPanel()
22062244 }
22072245 if (t->type == type_CvButtonbar)
22082246 {
2209- int subsize = settings.beginReadArray (QString (" buttonbar" )+i );
2247+ int subsize = settings.beginReadArray (QString (" buttonbar%1 " ). arg (i) );
22102248
22112249 if ( subsize == ((CvButtonbar*)t)->layout ()->count () )
22122250 icvLoadButtonbar ((CvButtonbar*)t,&settings);
@@ -2237,7 +2275,7 @@ void CvWindow::icvSaveControlPanel()
22372275 }
22382276 if (t->type == type_CvButtonbar)
22392277 {
2240- settings.beginWriteArray (QString (" buttonbar" )+i );
2278+ settings.beginWriteArray (QString (" buttonbar%1 " ). arg (i) );
22412279 icvSaveButtonbar ((CvButtonbar*)t,&settings);
22422280 settings.endArray ();
22432281 }
@@ -2397,14 +2435,14 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
23972435 flags |= CV_EVENT_FLAG_LBUTTON;
23982436 if (buttons & Qt::RightButton)
23992437 flags |= CV_EVENT_FLAG_RBUTTON;
2400- if (buttons & Qt::MidButton )
2438+ if (buttons & Qt_MiddleButton )
24012439 flags |= CV_EVENT_FLAG_MBUTTON;
24022440
24032441 if (cv_event == -1 ) {
24042442 if (category == mouse_wheel) {
24052443 QWheelEvent *we = (QWheelEvent *) evnt;
2406- cv_event = ((we-> orientation ( ) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
2407- flags |= (we-> delta ( ) & 0xffff )<<16 ;
2444+ cv_event = ((wheelEventOrientation (we ) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
2445+ flags |= (wheelEventDelta (we ) & 0xffff )<<16 ;
24082446 return ;
24092447 }
24102448 switch (evnt->button ())
@@ -2417,7 +2455,7 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
24172455 cv_event = tableMouseButtons[category][1 ];
24182456 flags |= CV_EVENT_FLAG_RBUTTON;
24192457 break ;
2420- case Qt::MidButton :
2458+ case Qt_MiddleButton :
24212459 cv_event = tableMouseButtons[category][2 ];
24222460 flags |= CV_EVENT_FLAG_MBUTTON;
24232461 break ;
@@ -2772,7 +2810,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
27722810{
27732811 icvmouseEvent ((QMouseEvent *)evnt, mouse_wheel);
27742812
2775- scaleView (evnt-> delta ( ) / 240.0 , evnt-> pos ( ));
2813+ scaleView (wheelEventDelta (evnt ) / 240.0 , wheelEventPos (evnt ));
27762814 viewport ()->update ();
27772815
27782816 QWidget::wheelEvent (evnt);
0 commit comments