In some part of my project, I want to get the reference of a window, from a list of opened windows. So, i'm doing this way:
QWidget* WindowUtil::mainWindow() {
QWidget* main_window = nullptr;
for(QWidget *window: QApplication::allWidgets()){
if(QString(window>metaObject()->className()).contains("Home")){
main_window = window;
break;
}
}
return main_window;
}
WindowUtil is class of my project and mainWindow() is a static method.
However, this solution doesn't work. The compiler says:
error: incomplete type 'QApplication' used in nested name specifier
for(QWidget *window : QApplication::allWidgets()){
^
And I'm stuck here.
Aucun commentaire:
Enregistrer un commentaire