Getting window geometry for all desktop windows



  • Ok, so I have a piece of software that needs to know the geometry and positions of all desktop windows. I have been searching far and wide for a Qt way of doing this, but it seems that I need to do some system specific coding to make it work.

    But, before I delve too deep into that, I'd like to put the question here, just in case there actually IS a Qt way of doing this. So basically:

    • I need some simple way of iterating all windows (including the ones that aren't part of my own software) and get their size and positions.

    I looked into using QApplication::desktopWidget and then calling grabWindow which then returns a pixmap with a width and height. It would sortof do what I want, but I still wouldn't know the positions and it's quite an expensive way of doing it. I need to do this every 30 ms so it's not exactly a solition after all. Just to let you know that I am aware of the grabWindow call.

    Any input would be appreciated.


  • Moderators

    no there is no Qt-way. This is actually far beyond of such a framework like Qt is.
    You need to use system specific APIs to do that.



  • @raven-worx I will look into platform specific code. Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.