Results 1 to 2 of 2

Thread: Using variable from dialog in another dialog

  1. #1
    Join Date
    May 2010
    Posts
    20
    Thanks
    7
    Qt products
    Qt4

    Default Using variable from dialog in another dialog

    Hi everyone...
    I have variable from type: integer
    its name for example num , I defined it in dialog1.h
    I stored value in it from user by lineEdit
    when user enter value, I change it to int and then store in num variable..

    now I need to use this variable in another file
    so, I must use it in dialog2.cpp file

    I called it like this:
    dialog1::num but it doesn't work!

    then I did that:

    dialog1* d=new dialog1(this);
    d->num;

    but also it doesn't work!

    please can anyone help me?!
    I don't have enough time..
    I must finish my project today

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Using variable from dialog in another dialog

    There are a few ways to do this. Check on google for some C++ tutorials, this is basic C++.

    Here are a few ways:
    1. Pass the object of your first dialog to your second, then you can use it to set and get values. I recommend you do this as this is the easiest way
    2. Use signals and slots
    3. Define a global singleton to store your settings and use the instance to set and get values. This breaks object oriented programming patterns though thus not really recommended.

Similar Threads

  1. Qt dialog
    By franco.amato in forum Qt Programming
    Replies: 8
    Last Post: 7th February 2010, 18:15
  2. how to dreate dialog with variable message
    By Petr_Kropotkin in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 09:23
  3. How to blur parent dialog when child dialog is displayed
    By abhilashajha in forum Qt Programming
    Replies: 4
    Last Post: 10th June 2009, 13:01
  4. Dialog to Dialog communication
    By jjbabu in forum Qt Tools
    Replies: 1
    Last Post: 1st October 2008, 10:54
  5. call the other dialog through dialog
    By narumi in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2008, 09:30

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.