How to separate functionality of tab pages from Qt main window class
In my application, I have QTabWidget with 3 pages with controls designed 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 to access the MainWindow::ui instance in my new class ? which is declared in private.
it is a qt-desktop application and platform is qt 4.8.1/win 7.
Re: How to separate functionality of tab pages from Qt main window class
Why do you want to access MainWindow ui?
Re: How to separate functionality of tab pages from Qt main window class
because I want to use the controls of tab pages in new class,.... after searching and from forums I come to know I have to pass ui instance as a parameter to another class where I have to use those controls. but I planned to create different widget ui files and attach it to my main tab widget, I hope this will serve my purpose.
Re: How to separate functionality of tab pages from Qt main window class
How passing widget UI to other class differ from accessing UI elements from i.e. MainWindow class? IMHO it's not separating interface but simply putting code in diff. place.
If You want to use UI widgets in/from different class, then I would create separate class with getter/setter approach. Then I would connect appropriate signals from UI to my separate class and pass only information that needs to be passed.
Re: How to separate functionality of tab pages from Qt main window class
Quote:
Originally Posted by
prady
because I want to use the controls of tab pages in new class,....
That doesn't require you to access MainWindow ui. You instantiate pages and place them in MainWindow and then you access methods of those instances from within MainWindow, not the other way round.
Re: How to separate functionality of tab pages from Qt main window class
Ok, I was using a single ui file with all the tab pages designed, now I created widgets for tab pages and and accessing the instance of those classes from MainWindow.