accessing parent form from a child form.how?

Discussion in 'C++' started by nass, Sep 21, 2006.

  1. nass

    nass Guest

    hello everyone,

    i have a mainForm, that is run basically from main.cpp.
    then i also have a childForm, that gets instanciated from within a
    function in mainForm. basically:

    #include "childrenforms.h"

    //etcetc

    class childrenForms;

    //etcetc

    childrenForms *childForm;

    //etcetc

    mainForm::showChildForm()
    {
    childForm = new childrenForm(..);
    childForm.show(); //to prepare the form for showing on screen
    childForm.exec(); //to run it
    }

    so far so good... however the mainForm also has a writeToFile()
    function..

    mainForm::writeToFile() {....}

    i need to make this visible to the childForm...
    so that i can basically somehow run the mainForm->writeToFile()
    function by calling it from within the childForm.
    how can i do that?
    thank you for your help
    nass
    nass, Sep 21, 2006
    #1
    1. Advertising

  2. nass

    Guest

    nass wrote:
    > hello everyone,
    >
    > i have a mainForm, that is run basically from main.cpp.
    > then i also have a childForm, that gets instanciated from within a
    > function in mainForm. basically:
    >
    > #include "childrenforms.h"
    >
    > //etcetc
    >
    > class childrenForms;
    >
    > //etcetc
    >
    > childrenForms *childForm;
    >
    > //etcetc
    >
    > mainForm::showChildForm()
    > {
    > childForm = new childrenForm(..);
    > childForm.show(); //to prepare the form for showing on screen
    > childForm.exec(); //to run it
    > }
    >
    > so far so good... however the mainForm also has a writeToFile()
    > function..
    >
    > mainForm::writeToFile() {....}
    >
    > i need to make this visible to the childForm...
    > so that i can basically somehow run the mainForm->writeToFile()
    > function by calling it from within the childForm.
    > how can i do that?
    > thank you for your help
    > nass


    Pass a pointer to the child form:

    mainForm::showChildForm()
    {
    childForm = new childrenForm(this);
    , Sep 21, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davout
    Replies:
    0
    Views:
    551
    davout
    Apr 18, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,119
    David Schwartz
    Dec 9, 2003
  3. Replies:
    0
    Views:
    207
  4. Noel Dolan
    Replies:
    0
    Views:
    231
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    142
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page