Hello.
Please excuse me for my poor english.

I am trying to write a program, and one of its functions will be manipulations with windowses of other programs.
In particular, moving them and making its screenshots.

I am trying to make screenshot with code like this one:
Qt Code:
  1. for (const auto& screen : QGuiApplication::screens()) {
  2. if (screen) {
  3. QPixmap screenshot = screen->grabWindow(window_id);
  4. if (!screenshot.isNull() && screenshot.save("screenshot.png")) {
  5. cout << "saved" << endl;
  6. }
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

However, to make it work, I have to create a Q*Application object:
Qt Code:
  1. QApplication a(argc, argv);
To copy to clipboard, switch view to plain text mode 

Without it, nothing works (QGuiApplication::screens() is empty).

In case where a program activelu uses Qt it is not a problem.
However, I am trying to make a small library, which can manipulate with windovs via qt, and use the library in my program.

So I want to make my program qt-independent (with exception of the manipulating library ofc).
In this case making global object of a qt type is looking bad.

So what is correct way to solve the task?
Make a singleton with QApplication inside the library?