Dynamically change text qlabel
问题 Sorry for my english. I need to change the text qlabel dynamically. class Game: { ... std::shared_ptr<QWidget> m_hint; QLabel *m_label; QHBoxLayout *m_layout; } void Game::setTextToHint(std::string str) { m_label = new QLabel(); m_layout = new QHBoxLayout(); m_label->setText(QString::fromUtf8(str.c_str())); m_layout->addWidget(m_label); m_hint->setLayout(m_layout); } And i use this function eg twice: setTextToHint("One"); setTextToHint("First"); But ultimately label = "One" Ok i understood. I