0

I used QApplication objects in gTest in Visual Studio.

int argc = 0;
char **argv = 0;
QMainWindow *window;

TEST() {
    app = new QApplication(argc, argv);
    window = new QMainWindow();
// Test Execution 
// Data gathering
    app.exec();
    delete window;
    window = new QMainWindow();
    delete app;
    app = new QApplication(argc, argv);
// Test Execution 
// Data gathering
    app.exec();
}

And it works pretty well.

If i am using the same snippet with Linux and the windows generated on the second call of exec() is empty and I have to kill the execution.

What is missing to get that working with Linux.

Making two separate tests does not work either

heitho
  • 61
  • 1
  • 7
  • Can you do it without initializing a new application? I don't think that's intended use. Secondly, if you are not using anything GUI-related you can try using `QCoreApplication` instead of `QApplication`. – Ronny Brendel Jan 17 '18 at 19:37
  • I tried app.exec(); app.exec(); but as result, I got no windows at all. Before I execute the app I initialize widgets. – heitho Jan 17 '18 at 20:22

1 Answers1

0

Ronny Brendel had the right Question in the comment.

The solution is not to reinitialize the QApplication.

delete app;
app = new QApplication(argc, argv);

must be removed.

heitho
  • 61
  • 1
  • 7