[Interest] mapToGlobal and mapToLocal
Mitchell Verter
mitchell.verter at gmail.com
Tue Sep 17 23:08:50 CEST 2013
The first code is:
if (button->geometry().contains( button->mapFromGlobal(
QPoint(kinect_x, kinect_y))))
This is failing in the nav bar. I made a mistake when I cut and pasted to
this email. No error in the code though
On Tue, Sep 17, 2013 at 4:47 PM, Mitchell Verter
<mitchell.verter at gmail.com>wrote:
> I have been having issues using mapToLocal and mapToLocal
>
> I am wondering whether there are issues with using these functions within
> laidout components? Laidout within the brower is a navigation bar; laidout
> within the navigation bar are a series of QPushButtons.
>
> Consistently, there is a 100-pixel discrepancy between where the mouse
> actually is and where QT seems to think it is. This problem occurs only
> within the nav bar. The mouse position is correctly detected in other
> parts of the browser .
>
> For example, the mouse was actually hovering over the RELOAD button when
> it was detected as hovering over the HOME button
> point= ( 567 , 112 ) HomeBtn QPoint(560,101) QPoint(603,132)
>
>
> I've tried different variations of this code but keep on getting the same
> error. Is something else going on here?
>
> Thanks
> Mitchell
>
>
> ===========
>
> CODE ONE
>
> if (button->geometry().contains(
> addressBar->mapFromGlobal(QPoint(kinect_x, kinect_y))))
> ====================
>
>
> CODE TWO
>
> bool NavigationBar::
> checkGlobalPoint(QWidget * widge, int kinect_x, int kinect_y)
> {
> QPoint UL = widge->mapToGlobal(widge->geometry().topLeft());
> QPoint LR = widge->mapToGlobal(widge->geometry().bottomRight());
>
> qDebug() << "point= (" << kinect_x << ", " << kinect_y << ") " <<
> widge->metaObject()->className() << " " << UL << " " << LR;
> if (kinect_x >= UL.x() && kinect_x <= LR.x() &&
> kinect_y >= UL.y() && kinect_y <= LR.y())
> {
> return true;
> }
> return false;
> }
>
> =============
>
>
> CODE THREE
>
> bool NavigationBar::checkGlobalPoint(QWidget * widge, int kinect_x, int
> kinect_y)
> {
>
> int * x1 ,* y1 , * x2, * y2;
> x1 = (int *)malloc(sizeof(int));
> y1 = (int *)malloc(sizeof(int));
> x2 = (int *)malloc(sizeof(int));
> y2 = (int *)malloc(sizeof(int));
>
> QRect geo = widge->geometry();
> geo.getCoords(x1,y1, x2, y2);
> QPoint UL = widge->mapToGlobal(QPoint(*x1, *y1));
> QPoint LR = widge->mapToGlobal(QPoint(*x2, *y2));
>
> if ((kinect_x >= UL.x()) &&
> (kinect_x <= LR.x()) &&
> (kinect_y >= UL.y()) &&
> (kinect_y <= LR.y()) )
> {
> return true;
> }
> return false;
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130917/7a25f069/attachment.html>
More information about the Interest
mailing list