Results 1 to 3 of 3

Thread: QLineEdit not updating as expected

  1. #1
    Join Date
    Apr 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLineEdit not updating as expected

    Dear All

    Please consider the following function:

    Qt Code:
    1. void CTL_Main::useDBParamteters1(QString DB_IP, int DB_PORT, QString DB_USER, QString DB_PASS){
    2.  
    3. MySQL_DB testing_query(DB_IP, DB_PORT, DB_USER, DB_PASS);
    4. float resultofquery = testing_query.getAIRTemperature();
    5.  
    6. QString results_string;
    7. results_string.setNum(resultofquery);
    8. qDebug() << results_string;
    9.  
    10. ui->lineAIRTemp->setText(results_string);
    11. QMessageBox::information(this, "Debug Data", "Current Temperature: " + results_string);
    12.  
    13. return;
    To copy to clipboard, switch view to plain text mode 

    This function instantiates a instance of the MySQL_DB class and passes the database parameters to the constructor, then runs the getAIRTemperature() method which loads the results into a float. I then do a dirty conversion into a QString.

    The correct value is displayed by qDebug() and in the QMessageBox but nothing is placed into QLineEdit (lineAIRTemp at line 10).

    This is driving me crazy, can anybody help?

    Many thanks
    Ishtar

  2. #2
    Join Date
    Oct 2008
    Posts
    71
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QLineEdit not updating as expected

    Are you sure that the text is not reset from some other part of the code?
    Try to handle this signal:
    Qt Code:
    1. void QLineEdit::textChanged ( const QString & text ) [signal]
    To copy to clipboard, switch view to plain text mode 
    And see what's happening to the text.

  3. #3
    Join Date
    Apr 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit not updating as expected

    Hi and many thanks for your help.

    Yes, absolutely sure because the QMessageBox at line 11 and the qDebug() at line 8 shows the value of this variable. It just doesn't update the QLineEdit. Any other ideas?

    Once again, thank you.
    Ishtar

Similar Threads

  1. Replies: 1
    Last Post: 16th February 2011, 08:06
  2. expected `)' before '*' token
    By vinod sharma in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2010, 07:57
  3. Expected class-name before '{' token
    By imagiro1 in forum Newbie
    Replies: 16
    Last Post: 16th June 2009, 11:37
  4. expected initializer before »)« token
    By Holy in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 16:24
  5. Expected lifetime of QModelIndex?
    By Ishark in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:18

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.