Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tag html on QString not applied when contains "\n"
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
qstringcolorhtml
2 Posts 2 Posters 1.2k Views
  • 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 Offline
    H Offline
    helenebro
    wrote on last edited by helenebro
    #1

    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
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

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

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved