Results 1 to 6 of 6

Thread: Pass variable from a form to another form

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Nov 2010
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Pass variable from a form to another form

    I am novice but my way is:

    principal.cpp
    Qt Code:
    1. void Principal::on_pushButton_facturacion_clicked()
    2. {
    3. Facturacion *form_factu = new Facturacion; //Create new form with other class
    4. form_factu->show();
    5.  
    6. QObject::connect(form_factu, SIGNAL(cambia(str_remote)), this, SLOT(muestramenu(str_local))); //Connect when is emit signal cambia in the child form and pass the string to local function
    7. }
    8.  
    9. void Principal::muestramenu(QString str_local)
    10. {
    11. qDebug() << "Back to main" << str_local;
    12. }
    To copy to clipboard, switch view to plain text mode 


    facturacion.h
    Qt Code:
    1. class Facturacion....
    2. {
    3. ....
    4. signals:
    5. void cambia(QString);
    6. }
    To copy to clipboard, switch view to plain text mode 


    facturacion.cpp
    Qt Code:
    1. void Facturacion::on_edit_onchange()
    2. {
    3. QString name;
    4. name = f_ui->edit->Text();
    5. emit cambia(name);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Sorry for errors and my bad english.
    Last edited by cygnus2k; 8th February 2011 at 18:24.

Similar Threads

  1. How can I access public variable parent Form
    By validator in forum Qt Programming
    Replies: 14
    Last Post: 18th December 2008, 21:12
  2. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  3. How to pass values in 1 form to another
    By maveric in forum Newbie
    Replies: 4
    Last Post: 5th June 2008, 07:18

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.