C++ (Qt)MainWindow *nw = qobject_cast<MainWindow*>( QApplication::topLevelWidgets()[ 0 ] );
C++ (Qt)MainWindow *nw = qobject_cast<MainWindow*>( QApplication::topLevelWidgets()[ 0 ] );Q_ASSERT( nw );// Используем....
C++ (Qt) MainWindow *nw = qobject_cast<MainWindow*>(QApplication::topLevelWidgets()[1]); QString query2 = nw->formReloadQuery();
C++ (Qt)class MainWindow : public QMainWindow{public: MainWindow(...) { Q_ASSERT_X( !m_mainWindow, "Повторное создание объекта MainWindow" ) m_mainWindow = this; ... } static MainWindow *mainWindow() { Q_ASSERT_X( m_mainWindow, "Объект MainWindow не создан" ); return m_mainWindow; } private: static MainWindow *m_mainWindow;};
class MainWindow : public QMainWindow { ... static MainWindow * Instance( void ) { return theMainWindow; } static MainWindow * theMainWindow; };MainWindow::MainWindow( .. ){ theMainWindow = this; ...}MainWindow::~MainWindow( void ){ ... theMainWindow = 0;}
C++ (Qt)undefined reference to MainWindow::theMainWindow;