Results 1 to 7 of 7

Thread: getting data from a Dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: getting data from a Dialog

    And if i want this working the opposite direction?
    Let's say i want that objects created from class a get some data from de base class.
    This is a constructor issue ... isn'it?
    Qt Code:
    1. #include "a.h"
    2. #include "ui_a.h"
    3.  
    4. a::a(QWidget *parent) :
    5. QDialog(parent),
    6. m_ui(new Ui::a)
    7. {
    8. m_ui->setupUi(this);
    9. m_ui->label.setText("data from the calling dialog!?!");
    10. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: getting data from a Dialog

    read about setter and getter functions. In your case it would be like:

    Qt Code:
    1. class a : public QDialog {
    2. Q_OBJECT
    3. public:
    4. //...
    5. void setSomeThing(QString str);
    6.  
    7. };
    8.  
    9. void a::setSomeThing(QString str)
    10. {
    11. // if needed check the content of str
    12. ui->someLineEdit->setText(str);
    13. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: getting data from a Dialog

    yess ... but the content of that str is somewhere in other Dialog that called this one.
    Am i missing something obvious?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: getting data from a Dialog

    Quote Originally Posted by graciano View Post
    Am i missing something obvious?
    Yes ;-)

    Qt Code:
    1. void Dialog::calla()
    2. {
    3. a x;
    4. x.setSomeThing("foo bar");
    5. x.exec();
    6. ui->a_lineEdit->setText(x.getA());
    7. }
    To copy to clipboard, switch view to plain text mode 

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

    graciano (21st August 2009)

  6. #5
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: getting data from a Dialog

    Wellll ... guess i need vacations.
    "I'll be back "

Similar Threads

  1. data rate transfer is decreasing in TCP connection
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 16:15
  2. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  3. Replies: 2
    Last Post: 23rd May 2007, 03:51
  4. Replies: 3
    Last Post: 17th May 2007, 13:50

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.