Qt Creator 4.6.2 on MacOS High Sierra setText() not working
Unsolved
General and Desktop
-
Hi
and you are positive that the label has a size and
not ultra small or anything like that ?
What if you place a label in Designer and set its text ? -
It sets it. It does not refresh. Hide and show it again. It will work. Seems like a bug to me as well.
-
Hi,
What version of Qt are you using ?
Can you provide a complete minimal example that shows that behavior ?
-
@valveCorp Just call repaint() after updating the text. It should work.
MyWidget::MyWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MyWidget) { ui->setupUi(this); ui->label->setText("Dheerendra"); this->m_lab = new QLabel("pthinks.com"); ui->verticalLayout->addWidget(m_lab); } void MyWidget::on_pushButton_clicked() { qDebug() << Q_FUNC_INFO << endl; this->m_lab->clear(); this->ui->label->setText("Dheeru"); this->m_lab->setText("http://www.pthinks.com"); this->repaint(); }
-
@dheerendra I'm wondering why repaint would be needed after updating QLabel text?
-
@jsulm It does not work if you no repaint(). Even update() is not working. Only repaint() works.
-
@dheerendra But QLabel should repaint when its text is changed, shouldn't it?
-
@jsulm true. But it is not working. It is work-around.