user2612344
user2612344

Reputation: 77

Get all windows in Qt

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 

    }  

Upvotes: 2

Views: 4001

Answers (1)

David S.
David S.

Reputation: 730

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.

Upvotes: 3

Related Questions