Results 1 to 4 of 4

Thread: A form returning an object.

  1. #1
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default A form returning an object.

    Hi all,

    I know how to pass an object to a form which can be done through the constructor.
    What I don't now is how i can return an object used and declared in a form.

    For example i have two forms frmA and frmB. In frmB i have a linedit widget and i want to pass these contents to an object and then pass the object to formA. The idea behind it is that I can pass lots of data through an abject (say for example the contents of 20 lineedits through an object).

    Can please one write a sample code for that?

    Many thanks in advance.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A form returning an object.

    I assume u mean dialogs by forms .
    You can always have functions to retrieve the data from dialog.
    For eg -

    Qt Code:
    1. MyDialog dlg;
    2. if(dlg.exec() == Qt::Accepted)
    3. {
    4. QString text = dlg.getLineEditText(); // You get the text of the line edit here
    5.  
    6. // Now pass it on to another dialog or use it as u want
    7. dlg2.setLineEditText(text);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Hope you get the idea

  3. #3
    Join Date
    Aug 2008
    Posts
    52
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: A form returning an object.

    Many thanks for the reply.

    Is the object of the dialogue killed when the user closes the form? or if it is not do i have to delete this object as soon as i read the things that i want to read form it (ex lineedits).

    What is the .getlineedit and setlineedit?. I cant find them in the documentation

    Many thanks

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A form returning an object.

    The object has scope of a normal object. I hope u know c++

    the getLinedEditText, setLineEditText are user defined functions. I assume you had inherited the dialog, and those are member functions of ur class.

  5. The following user says thank you to aamer4yu for this useful post:

    cbarmpar (8th September 2008)

Similar Threads

  1. Passing an object from one form to the other.
    By cbarmpar in forum Qt Programming
    Replies: 10
    Last Post: 3rd September 2008, 14:12
  2. visible main form?
    By triperzonak in forum Newbie
    Replies: 1
    Last Post: 12th June 2008, 09:00

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.