Results 1 to 10 of 10

Thread: Passing variables between forms.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Passing variables between forms.

    There isn't a single way of solving this (like most problems)

    Have a public method on your main window which accepts a username and password?

    Or perhaps the login form could be given a structure which it fills in and returns.

    Or you could use a singleton which contains such information and everyone accesses.

  2. #2
    Join Date
    Oct 2010
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Re: Passing variables between forms.

    Hi squidge... could you show me an example of how to do this? If not, could your direct me to an article of how to do this.

    I don't care if the code is messy, etc... i just want to get this to work. I'll tidy it up later

    Thanks so much

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Passing variables between forms.

    What bit are you struggling with?

    I assume you already know how to create a public method, thats basic C++.
    The contents of that method - assigning parameters to class member variables, is also basic C++.

    So the only part left is the actual call, and so you simply instantiate a copy of the login form from within your main window (either allocate it on the stack and call a function which doesn't return until the login dialog is closed, or use the 'new' operator to allocate from the heap)

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: Passing variables between forms.

    Quote Originally Posted by Splatify View Post
    Hi squidge... could you show me an example of how to do this? If not, could your direct me to an article of how to do this.

    I don't care if the code is messy, etc... i just want to get this to work. I'll tidy it up later

    Thanks so much
    This is not a Qt problem, its a C++ problem. How do you pass data around classes?

  5. #5
    Join Date
    Oct 2010
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8
    Thanked 1 Time in 1 Post

    Thumbs up Re: Passing variables between forms.

    Ok I have successfully managed to do this now. Thanks so much for all your help. It really is appreciated

    Edit:

    Here is a link:
    http://www.codeproject.com/KB/cs/pas...een_forms.aspx
    I found which helped explain things in a fair amount of detail. I decided to use the first approach as it was the easiest and involved changing less of my code. In future I think i will plan a bit more before starting a project

    Thanks once again.
    Last edited by Splatify; 21st February 2011 at 11:17. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 25th November 2010, 16:02
  2. Multiple Forms and vertical layout in forms
    By eva2002 in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 05:05
  3. Replies: 2
    Last Post: 25th June 2009, 19:47
  4. Replies: 2
    Last Post: 17th October 2006, 19:25
  5. pass variables between 2 forms
    By restiz in forum Qt Programming
    Replies: 7
    Last Post: 17th June 2006, 16:13

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