ui->comboBoxMy
MainWindow mw;mw.myFunc();
Mainwindow *mw;
extern Mainwindow *mw;
mw = this;
mw->myFunc();
// mainwindow.cppMainWindow * theMainWin = nullptr;
// win1.cppextern MainWindow * theMainWin;...if (theMainWin) theMainWin->DoSomething();
C++ (Qt)// MainWindow.hclass MainWindow {..public static MainWindow * Instance( void ) { return m_instance; }private: static MainWindow * m_instance;};
C++ (Qt)// MainWindow.cppMainWindow * MainWindow::m_instance = nullptr; MainWindow::MainWindow(.. ){ Q_ASSERT(m_instance == nullptr); m_instance = this; ...} MainWindow::~MainWindow( void ){ Q_ASSERT(m_instance == this); m_instance = nullptr; ...}
C++ (Qt)// win1.cpp#include "MainWindow.h"...auto * inst = MainWindow::Instance();if (inst) inst->DoSomething();