How to separate tab functionality from the Qt main window class

In my application, I have a QTabWidget with 3 pages with the controls created in it using Qt creator 2.4.1. Now I want to separate the functionality of these pages from MainWindow by creating new classes.

My question is: how do I access an instance of MainWindow :: ui in my new class? which is declared closed.

This application is for qt-desktop, and the platform is qt 4.8.1 / win 7.

+4
source share
1 answer

You cannot directly access ui MainWindow on your tabs. Since your QTabWidget is a child of MainWindow (this is how it should be implemented and assumes you did it).

But you can achieve this with signals and slots. You can perform operations in your MainWindow by writing slots to signals coming from individual tabs.

OR

You can write a method on MainWindow that will work on it. And name it from the tab widget -

this->parent->parent->uiMethod(); // this(Tab) -> parent(QTabWidget) -> parent(MainWindow) -> [related method] 
+1
source

All Articles