Results 1 to 4 of 4

Thread: Get data from a QLineEdit, inside a Qt Designer for class

  1. #1
    Join Date
    Jan 2013
    Posts
    43
    Thanks
    27
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Get data from a QLineEdit, inside a Qt Designer for class

    I have a QMainWindow (w) thal creates an instance of a myDialog at a certain moment.
    In the action used to manipulate this case i have:
    Qt Code:
    1. myDialog dialog;
    2. dialog.exec();
    3. info = dialog.?????????
    To copy to clipboard, switch view to plain text mode 

    I suppose that a get function is not needed to fetch some text from a lineEdit in the ui!
    This is a Qt Designer Form Class (myDialog.h + myDialog.cpp + myDialog.ui).
    How do i get there?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Get data from a QLineEdit, inside a Qt Designer for class

    I suppose that a get function is not needed to fetch some text from a lineEdit in the ui!
    It is better to have a function to return the text of the line edit.

    or

    You could also make the ui variable public and but is very good solution.
    Qt Code:
    1. info = dialog.ui->lineEdit->text();
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2013
    Posts
    43
    Thanks
    27
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get data from a QLineEdit, inside a Qt Designer for class

    I see.
    But the ui is created in the private section ... so i better leave it there
    I'm going for the getset style.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get data from a QLineEdit, inside a Qt Designer for class

    Quote Originally Posted by Santosh Reddy View Post
    You could also make the ui variable public and but is very good solution.
    Indeed!
    It also requires that the code using myDialog needs to have the include for the generated header that declares the ui object. Thus forcing an unnecessary rebuild of the using code whenever the UI file changes.

    Cheers,
    _

Similar Threads

  1. How to read value which written inside the QLineEdit
    By RENOLD in forum Qt Programming
    Replies: 4
    Last Post: 16th February 2012, 13:59
  2. Replies: 7
    Last Post: 18th August 2011, 14:43
  3. Replies: 2
    Last Post: 20th July 2010, 15:35
  4. How can I set a layout to a dock inside Qt Designer?
    By ricardo in forum Qt Programming
    Replies: 4
    Last Post: 1st May 2009, 10:17
  5. declaring objects inside Designer
    By mickey in forum Qt Tools
    Replies: 8
    Last Post: 14th March 2006, 17:25

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.