Tag html on QString not applied when contains "\n"



  • Hi,
    I would like color some word on QLabel but html tag is displayed if my text contains "\n".

    ui->mylayout->addWidget(new QLabel(determineText()));
    
    QString MainWindow::determineInfoMixedCode(TableURC *myTable)
    {
       QString text = "test ";
        text += "\n";
        text +=" <font color=red>with</font> color";
        return text;
    }
    

    display :

    test 
     <font color=red>with</font> color
    

    But if I delete "\n", it works fine

    QString MainWindow::determineInfoMixedCode(TableURC *myTable)
    {
      QString text = "test ";
       text +=" <font color=red>with</font> color";
        return text;
    }
    


  • Then use "<br>" instead of "\n"


Log in to reply
 

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