2

I want to get all opened non qt window from qt application and display them , i get all opened window but i can't display their names or positions.

this->_WindowsList = QGuiApplication::allWindows(); // i get all windows

 for (uint i = 0 ; i< _WindowsList.size() ; i++)
    {
        this->ui->listWidget->addItem(_WindowsList.at(i)->title()); // no name are displayed just rows 

    }  
user2612344
  • 77
  • 1
  • 6
  • 1
    You're using a [reserved identifier](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier). – chris Dec 22 '13 at 13:30
  • Read more about [EWMH](http://en.wikipedia.org/wiki/Extended_Window_Manager_Hints)... – Basile Starynkevitch Dec 22 '13 at 13:32
  • `QGuiApplication::allWindows` returns all the windows belonging to the application, not all the toplevel windows in the system. As of Qt 5.2, there's no Qt method for doing that. – peppe Dec 22 '13 at 13:37
  • Is there any solution to make it (cross platform solution) – user2612344 Dec 22 '13 at 13:40

1 Answers1

3

There is no "universal Qt way" of enumerating all the active windows opened in your environment. There are different ways of doing this on different platforms/environments - your best bet is detecting the host operating system via QSysInfo() and then using OS specific code.

Here are some basic examples:

  • Enumerating windows on systems with X11 using xlib
  • Using EnumWindows() on Microsoft Windows via the WinAPI
  • I didn't really find a clear cut way of doing this on Mac OS X, but this SO question should be able to help point you in the right direction.
Community
  • 1
  • 1
David S.
  • 730
  • 1
  • 7
  • 23
  • QT != Qt, Also, please try to eliminate the external links when possible with inline content. – László Papp Dec 22 '13 at 14:00
  • @LaszloPapp: Fixed the QT vs Qt issue, sorry about that. As for the formatting - what do you recommend I do? I just wanted to provide as much information as possible. – David S. Dec 22 '13 at 14:05
  • Thanks. I would personally collect the main points of the external knowledge into your answer. Also, please remove things like "Cheers!" as well. :-) – László Papp Dec 22 '13 at 14:06
  • 2
    You'll need to detect OS with compiler defines and `#ifdef` preprosessor directives... OS specific code usually does not even compile for wrong OS, so runtime mechanism like `QSysInfo` isn't possible. – hyde Dec 22 '13 at 14:08