Results 1 to 3 of 3

Thread: Inputting values to GUI

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2015
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Inputting values to GUI

    I am using a line edit on my gui...I need to get the values entered on the text field when i press go....thats not happening...everything goes fine if i hard code those values...please help!!

    void MainWindow:n_pushButton_clicked()
    {



    QLineEdit lineEdit;
    QLineEdit lineEdit_2;
    QLineEdit lineEdit_3;



    int n=lineEdit.text().toInt();
    int rows=lineEdit_2.text().toInt();
    int columns=lineEdit_3.text().toInt();
    qDebug()<<n;



    its showing n as '0'...I have not even initialised n..

  2. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Inputting values to GUI

    If you have written something like your code snippet then the line edits are local in on_pushButton_clicked() and, most likely, shadowing the "right ones" line edits. You are entering values in the "right ones" line edits but the local ones are left empty. That's why you are getting nulls.
    (1) see the output of the line edits as QStrings (remove toInt()). Are the strings empty? Do they contain what they should?
    (2) see the result of the toInt() (do not default the first toInt() parameter). Is the result state true?

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

    gsabhishek (19th February 2015)

Similar Threads

  1. Replies: 5
    Last Post: 27th November 2014, 10:15
  2. Replies: 1
    Last Post: 31st December 2012, 08:06
  3. How to convert string hex values to its real binary values?
    By AttilaPethe in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 22:47
  4. Inputting Into Lists
    By kiyoutee in forum Newbie
    Replies: 2
    Last Post: 2nd March 2011, 07:48
  5. Replies: 2
    Last Post: 27th November 2008, 10:16

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.