Results 1 to 3 of 3

Thread: Best way for a parent class to know value chosen on child class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    6
    Thanked 6 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Best way for a parent class to know value chosen on child class

    Hello,

    I have a MainWindow class, on an action I create a new project type selector.

    MainWindow.cpp
    Qt Code:
    1. ...
    2. void MainWindow::on_actionFileNew_triggered()
    3. {
    4. NewDocumentSelector newdocumentselector;
    5. newdocumentselector.exec();
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 

    I want MainWindow to know the type selected
    Should I
    1) Emit a signal in NewDocumentSelector and connect it to MainWindow.
    or
    2) Pass MainWindow into NewDocumentSelector on initilization,
    Qt Code:
    1. NewDocumentSelector newdocumentselector(MainWindow);
    To copy to clipboard, switch view to plain text mode 
    which will then be used in NewDocumentSelector as
    Qt Code:
    1. MainWindow.thisTypeSelected();
    To copy to clipboard, switch view to plain text mode 
    or
    Is there another way? I want to follow Qt's MV pattern.
    In other words I want to access parent class instance.
    I have attached my project if you require more detail.

    Thanks
    Attached Files Attached Files
    Last edited by scarecr0w132; 4th October 2014 at 03:04.

Similar Threads

  1. Replies: 4
    Last Post: 4th March 2014, 19:28
  2. How to access to methods of parent class
    By tonnot in forum General Programming
    Replies: 3
    Last Post: 29th June 2011, 07:04
  3. Replies: 4
    Last Post: 16th March 2011, 17:12
  4. No CSS in child class
    By kartun in forum Newbie
    Replies: 0
    Last Post: 2nd February 2011, 10:01
  5. Determine Class Type of QObject Parent
    By photo_tom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 17:42

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
  •  
Qt is a trademark of The Qt Company.