PDA

View Full Version : QLineEdit not updating as expected



Ishtar
28th April 2010, 00:16
Dear All

Please consider the following function:



void CTL_Main::useDBParamteters1(QString DB_IP, int DB_PORT, QString DB_USER, QString DB_PASS){

MySQL_DB testing_query(DB_IP, DB_PORT, DB_USER, DB_PASS);
float resultofquery = testing_query.getAIRTemperature();

QString results_string;
results_string.setNum(resultofquery);
qDebug() << results_string;

ui->lineAIRTemp->setText(results_string);
QMessageBox::information(this, "Debug Data", "Current Temperature: " + results_string);

return;


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

psih128
28th April 2010, 10:16
Are you sure that the text is not reset from some other part of the code?
Try to handle this signal:

void QLineEdit::textChanged ( const QString & text ) [signal]
And see what's happening to the text.

Ishtar
28th April 2010, 12:09
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