Results 1 to 6 of 6

Thread: How to separate functionality of tab pages from Qt main window class

  1. #1
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    21
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to separate functionality of tab pages from Qt main window class

    Why do you want to access MainWindow ui?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    21
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default 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.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to separate functionality of tab pages from Qt main window class

    Quote Originally Posted by prady View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    prady (27th July 2012)

  7. #6
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    21
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

Similar Threads

  1. How to decide whether to make a separate class for widgets of a window?
    By TheIndependentAquarius in forum Qt Programming
    Replies: 4
    Last Post: 15th February 2012, 07:51
  2. Replies: 1
    Last Post: 20th January 2012, 04:39
  3. Replies: 0
    Last Post: 8th March 2011, 22:08
  4. separate class using an interface
    By qt_gotcha in forum Newbie
    Replies: 7
    Last Post: 3rd March 2010, 21:54
  5. Replies: 4
    Last Post: 26th June 2007, 19:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.