Commit d84c7e51 authored by Gregory Morse's avatar Gregory Morse Committed by Alexander Alekhin

Merge pull request #10649 from GregoryMorse:patch-3

* Fix for QT image window rectangle

* Update window_QT.h

* Update window_QT.cpp

* trailing whitespace

* highgui: fix QT getWindowImageRect()
parent c89ae6e5
......@@ -967,13 +967,7 @@ CvRect GuiReceiver::getWindowRect(QString name)
if (!w)
return cvRect(-1, -1, -1, -1);
QPoint org = w->myView->mapToGlobal(new QPoint(0, 0));
#ifdef HAVE_QT_OPENGL
if (isOpenGl()) {
return cvRect(w->myView->pos().x() + org.x, w->myView->pos().y() + org.y, w->myView->width(), w->myView->height());
} else
#endif
return cvRect(w->myView->viewport()->pos().x() + org.x, w->myView->viewport()->pos().y() + org.y, w->myView->viewport()->width(), w->myView->viewport()->height());
return w->getWindowRect();
}
double GuiReceiver::isFullScreen(QString name)
......@@ -1781,6 +1775,13 @@ void CvWindow::setRatio(int flags)
myView->setRatio(flags);
}
CvRect CvWindow::getWindowRect()
{
QWidget* view = myView->getWidget();
QRect local_rc = view->geometry(); // http://doc.qt.io/qt-5/application-windows.html#window-geometry
QPoint global_pos = /*view->*/mapToGlobal(QPoint(local_rc.x(), local_rc.y()));
return cvRect(global_pos.x(), global_pos.y(), local_rc.width(), local_rc.height());
}
int CvWindow::getPropWindow()
{
......
......@@ -299,6 +299,7 @@ public:
double getRatio();
void setRatio(int flags);
CvRect getWindowRect();
int getPropWindow();
void setPropWindow(int flags);
......
......@@ -84,7 +84,8 @@ void CV_HighGuiOnlyGuiTest::run( int /*start_from */)
waitKey(500);
ts->printf(ts->LOG, "GUI 8\n");
getWindowImageRect("Win");
Rect rc = getWindowImageRect("Win");
std::cout << "window image rect: " << rc << std::endl;
ts->printf(ts->LOG, "GUI 9\n");
destroyAllWindows();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment