Results 1 to 11 of 11

Thread: Passing an object from one form to the other.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Passing an object from one form to the other.

    You mean something like this?
    Qt Code:
    1. class A : public QWidget {
    2. Q_OBJECT
    3. public:
    4. A(QWidget *parent = 0) : QWidget(parent){
    5. QVBoxLayout *l = new QVBoxLayout(this);
    6. le1 = new QLineEdit;
    7. le2 = new QLineEdit;
    8. connect(pb, SIGNAL(clicked()), SLOT(onClick()));
    9. l->addWidget(le1);
    10. l->addWidget(le2);
    11. l->addWidget(pb);
    12. }
    13. public slots:
    14. void onClick(){
    15. QDialog dlg;
    16. QVBoxLayout *l = new QVBoxLayout(&dlg);
    17. QLabel *lab = new QLabel;
    18. l->addWidget(lab);
    19. lab->setText(le1->text()+" "+le2->text());
    20. dlg.exec();
    21. }
    22. private:
    23. QLineEdit *le1, *le2;
    24. };
    To copy to clipboard, switch view to plain text mode 
    The other "form" is the dialog in this case...

  2. The following user says thank you to wysota for this useful post:

    cbarmpar (3rd September 2008)

Similar Threads

  1. Replies: 4
    Last Post: 12th August 2008, 01:55
  2. passing an object
    By mickey in forum General Programming
    Replies: 3
    Last Post: 16th January 2008, 10:27
  3. Replies: 2
    Last Post: 17th May 2006, 21:01
  4. Passing Object to dll
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 09:50
  5. passing a QPainter object to widgets
    By vratojr in forum Qt Programming
    Replies: 9
    Last Post: 11th January 2006, 15:27

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.