Call MainWindow function from static one
Unsolved
General and Desktop
-
Hello,
How to solve problem defined below? How to call
nst()
fromst()
? I suppose I need to get pointer of class object that hasnst()
method..h
namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); void nst(); static void st(); private slots: private: Ui::MainWindow *ui; };
*.cpp
Ui::MainWindow *inst =NULL; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); inst=ui; i=this; } MainWindow::~MainWindow() { delete ui; } void MainWindow::nst() { } void MainWindow::st() { if (inst != NULL) inst->nst(); }
-
Hi,
First by reviewing your design. Trying to call a member function from a static method of the same class is sign of something fishy going on.