【问题标题】:QLabel not updating properly [duplicate]QLabel 未正确更新 [重复]
【发布时间】:2019-09-11 03:54:19
【问题描述】:

我正在尝试在处理后更新 QLabels,并且我使用了 SIGNALS 和 SLOTS。

信号:

void LayerCountUpdate(int, double, double);

方法:

LayerCountUpdate(TotalLayers, formatting->GetPrintTime(), formatting->GetResinConsumption());

插槽:

void ui_prt_settings::UpdateUIInfo(int count, double time, double cost)
{
    _ui->info_LayerCount->setText(QString::number(count));
    _ui->info_volumeValue->setText(QString::number(cost));
    _ui->info_timeEstimate->setText(QDateTime::fromTime_t(time).toUTC().toString("hh:mm:ss"));

    qDebug()<< _ui->info_LayerCount->text();
    qDebug()<< _ui->info_volumeValue->text();
    qDebug()<< _ui->info_timeEstimate->text();
}

据推测,标签输出与 QDebug 中显示的不匹配。如果 QLabel "infoLayerCount" 上的预期文本为 12,则它仅显示 1。如果我尝试其他数据,它仍然只显示第一个数字。

【问题讨论】:

    标签: c++ qt qlabel


    【解决方案1】:

    我通过为 QLabel 添加 adjustSize(); 函数来解决此问题。

    【讨论】:

      猜你喜欢
      • 2021-03-19
      • 2021-12-14
      • 1970-01-01
      • 2021-10-26
      • 1970-01-01
      • 2021-03-15
      • 1970-01-01
      • 2021-11-03
      • 2018-01-20
      相关资源
      最近更新 更多