Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    General and Desktop
    qstring color html
    2
    2
    955
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      helenebro last edited by helenebro

      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;
      }
      
      1 Reply Last reply Reply Quote 0
      • SeeLook
        SeeLook last edited by

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

        1 Reply Last reply Reply Quote 4
        • First post
          Last post