I wanted to display the specified content in the label (Client::saveData, a static variable),but I couldn't do it anyway. QMessageBox::information works, and qDebug() outputs the correct content, but it just doesn't show up on the label.
void S8524Widget::setTandHLabel()
{
qDebug() << Client::saveData;
QMessageBox::information(NULL,"OK","OK");
ui->tempText->setAlignment(Qt::AlignCenter);
QString tempdata(Client::saveData.left(2));
ui->tempText->setText(tempdata);
//ui->tempText->setProperty("text",tempdata);
//ui->tempText->setStyleSheet("setProperty: TEST;");
QString var = ui->tempText->text();
QString humiditydata(Client::saveData.right(2));
ui->humidityText->setText(humiditydata);
QString vae = ui->humidityText->text();
ui->ProgramNameText->setPlainText(tempdata);
ui->TimeStatusText->setPlainText(tempdata);
ui->StepStatusText->setPlainText(tempdata);
qDebug() << var;
qDebug() << vae;
}
Client::saveData prints correctly. If I put settext in the constructor, it works fine, but I need it to update the text dynamically. In this function, even setText (“Tempdata”)
doesn't work. If you save Ui-> tempText
as a variable, calling setText from the mainwindow won't work either.
Aucun commentaire:
Enregistrer un commentaire