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"
Forum Updated to NodeBB v4.3 + New Features

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 3 Watching
  • 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 6 Mar 2017, 11:37 last edited by helenebro 3 Jun 2017, 11:39
    #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
    • S Offline
      S Offline
      SeeLook
      wrote on 6 Mar 2017, 11:40 last edited by
      #2

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

      1 Reply Last reply
      4

      2/2

      6 Mar 2017, 11:40

      • Login

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