mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
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()
This commit is contained in:
parent
c89ae6e537
commit
d84c7e5143
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user