Results 1 to 6 of 6

Thread: Finding a QWidget from a screen XY

  1. #1
    Join Date
    Aug 2009
    Location
    Lancashire UK
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Finding a QWidget from a screen XY

    Is there the equivalent in Qt of the WindowFromPoint (win32) or XTranslateCoordinates (X-windows) method, which returns a window (preferably a QWidget) given a screen(global) x,y ? I have trawled the doc, but can't find one.

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Finding a QWidget from a screen XY

    Try:
    Qt Code:
    1. QWidget * QApplication::widgetAt ( const QPoint & point ) [static]
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2009
    Location
    Lancashire UK
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Finding a QWidget from a screen XY

    Many thanks. Got it. Must get new glasses.

  4. #4

    Default Re: Finding a QWidget from a screen XY

    Quote Originally Posted by yogeshgokul View Post
    Try:
    Qt Code:
    1. QWidget * QApplication::widgetAt ( const QPoint & point ) [static]
    To copy to clipboard, switch view to plain text mode 
    Hi

    I have the same need but this call doesn't seem to work for me. I need to know if QT have a call able to get the handle of a child control (like, for example, a text box) present at specified xy coordinates (like WindowFromPoint API do). Reading the documentation of this call it said:

    Returns the widget at global screen position point, or 0 if there is no Qt widget there.

    Than it seem it can detect only qt widget and not standard widget.

    Do you know if using qt is possible to hqve a call act like WindowFromPoint but working for all child controls in windows, linux and mac?

    Thank you

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Finding a QWidget from a screen XY

    QApplication::widgetAt() works for all the widgets in the Qt application itself, top-level or child, thinly wrapped native or fully Qt. A Qt application cannot return a QWidget* for a non-Qt widget, or for an arbitrary widget in another application for obvious reasons. Use the Windows API if you want a Windows API handle to the window at the specified location. Do whatever the equivalent is for the Mac OS X and X11 environments. Just wanting to do this sort of thing means your application is almost certainly going to be platform-dependent anyway.

  6. #6

    Default Re: Finding a QWidget from a screen XY

    Hi

    Thank you for reply. I could develop different code based to the running platform. I know how to do under windows, just found an example seem working in the same way for mac but I still miss the linux side. Do you know if linux have some api similar to WindowFromPoint()?

    Thank you

Similar Threads

  1. Promoting the parent QWidget of a QWidget form
    By extrakun in forum Qt Tools
    Replies: 6
    Last Post: 16th April 2010, 14:19
  2. Replies: 0
    Last Post: 11th November 2008, 15:36
  3. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  4. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05
  5. Setting manually cursor position on multi screen systems
    By irreriwan in forum Qt Programming
    Replies: 0
    Last Post: 4th March 2008, 09:47

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.