Results 1 to 7 of 7

Thread: how to get text from line edit after user clicks the submit button

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2018
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default how to get text from line edit after user clicks the submit button

    i have window with a label and a push button. When user clicks the button it takes them to another window with a line edit and a submit button.Now i want the text which user typed to replace the text of label in my first window.
    ]i have successfully made the program except that when user types the text in line edit no matter what the text of label is changed to blank(that is no text). I know this is because QString which i am using to set label of the text is initialized to null and as soon as the new window is created a null initialized QString is set to the text of label. I am aware of the fact that i need to use signals and slots but just couldn't figure out what to connect and to what?

    please if possible try to give code example

    any help will be seriously appreciated.
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: how to get text from line edit after user clicks the submit button

    Write a signal in your second window which emits the string and connect that signal to a slot in your main window.
    Ex :
    .
    .
    emit sinal_xyz("Your string from line edit ");
    connect (..;SIGNAL(sinal_xyz(QString),..;SLOT(slot_xyz(QSt ring));

  3. The following user says thank you to shivendra46d for this useful post:

    jshobhit (1st June 2018)

  4. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to get text from line edit after user clicks the submit button

    Show how this "another window" is activated.

  5. #4
    Join Date
    Jun 2018
    Posts
    3
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: how to get text from line edit after user clicks the submit button

    thanx this was exactly what i needed

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. button to save line edit text to file
    By davidrhcp in forum Newbie
    Replies: 6
    Last Post: 7th May 2014, 10:41
  3. Clear button in line edit
    By MTK358 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2010, 13:27
  4. clear button for line edit
    By jayreddy in forum Qt Programming
    Replies: 6
    Last Post: 3rd December 2009, 04:36
  5. Line edit and push button
    By dela in forum Newbie
    Replies: 1
    Last Post: 10th December 2008, 16:10

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.