QMainWindow* getMainWindow()
{
foreach (QWidget *w, qApp->topLevelWidgets())
if (QMainWindow* mainWin = qobject_cast<QMainWindow*>(w))
return mainWin;
return nullptr;
}
二:通过QApplication获取
auto tip = qApp->findChild<QMainWindow*>(QMainWindow.objectName);