Not able to set color and variable to Qt SetText (Solved)



  • I could
    ui->label->setText(StationList[1]);
    but i could not set color and variable to Qt SetText.
    Not able to do it for many hours.

                QColor color = cyan;
                QString Text;
                QString fonttemplate = tr("<font color='%1'> %2</font>");
    
                //ui->labelCurrentStation->setText("<font color='cyan'> Talad  </font>");
                ui->labelCurrentStation->setText(fonttemplate.arg(cyan,Text));


  • found the answer.

    ui->label->setText(QString("<font color='cyan'> %1</font>").arg(StationList[2]));

    It work



  • Please mark in the title of the post [SOLVED]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.