Results 1 to 3 of 3

Thread: getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget

  1. #1
    Join Date
    Apr 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget

    Hello folks,

    I'm looking for a way to retrieve what widget is under position x,y including the ones inside QGraphicsProxyWidgets.
    QApplication and QWidget's methods return the scene widget instead of the widget inside it.

    If that's not possible.. if there's a way to post a mouse event "globally" that will reach the children widget at certain position, that would do the trick. I'm using postEvent, but I have to pass the target widget, so I have to find that widget first.

    Thanks a lot for any help
    Last edited by lgvier; 24th April 2009 at 09:17.

  2. #2
    Join Date
    Apr 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Smile Re: getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget

    Hello,

    I'll answer myself in case somebody needs the same thing in the future..

    You map the global coordinates to the view:
    Qt Code:
    1. QPoint relativePos = view->mapFromGlobal(pos);
    To copy to clipboard, switch view to plain text mode 

    Then the view local coordinates to the scene:
    Qt Code:
    1. QPointF scenePos = graphicsView->mapToScene(relativePos);
    To copy to clipboard, switch view to plain text mode 

    And finally the scene pos to the GraphicsItem pos
    Qt Code:
    1. QPointF sceneRelPos = item->mapFromScene(scenePos);
    To copy to clipboard, switch view to plain text mode 

    Now proxy->widget()->childAt(sceneRelPos.toPoint) will return the widget that was hit inside the proxy.

    Cheers
    Geovani

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: getWidgetAt/getChildAt(global position) for elements under QGraphicsProxyWidget

    Excuse me, what can we use these things to do??
    Can we retrieve the position of the mouse out of the application interface??
    Thanks

Similar Threads

  1. QTextEdit restore cursor position
    By artur231 in forum Qt Programming
    Replies: 3
    Last Post: 15th May 2014, 22:02
  2. position of an item in a QStringList
    By jaca in forum Newbie
    Replies: 4
    Last Post: 29th May 2008, 05:49
  3. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.