Hi all,
I am using Qt 4.3 , I want to get MainWindow of the particular Application?
How to do this?
Hi all,
I am using Qt 4.3 , I want to get MainWindow of the particular Application?
How to do this?
Thanks,
Rajesh.S
Simple. Make a QMainWindow singleton subclass.
sorry , I want to get instance of mainwindow of the application from some other classes in the same application.
Thanks,
Rajesh.S
Yes, I know. And you should do it by implementing your QMainWindow subclass as a singleton.
we can make qMainWindow as singleton , how to get instance.![]()
Thanks,
Rajesh.S
and in the cpp don't forget to initialize the static member to NULL.Qt Code:
{ private: static MyWindow* instance; protected: public: static MyWindow* getInstance() { if(!instance) { instance = new MyWindow(); } return instance; } };To copy to clipboard, switch view to plain text mode
Next, you can use this in other classes just by including the MyWindow header:
Qt Code:
#include "MyWindow.h" ... MyWindow* mainWindow = MyWindow::getInstance(); ...To copy to clipboard, switch view to plain text mode
Bookmarks