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. HTML tags in QLabel
Forum Updated to NodeBB v4.3 + New Features

HTML tags in QLabel

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.7k Views 1 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.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    Hi,

    i use html tags to format my textes. But sometimes it seams not to work:

    if (!ClientName.isEmpty() && !oldChannel.isEmpty() && !newChannel.isEmpty())
    	{
    		// joined my channel
    		if (newChannelID == getCurrentChannel(serverConnectionHandlerID))
    			getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">entered from</font> %2</font>").arg(ClientName).arg(oldChannel));
    		// quit my channel
    		else if (oldChannelID == getCurrentChannel(serverConnectionHandlerID))
    			getController(serverConnectionHandlerID)->addChatLine(QString("<font color=\"#00FFFF\">%1 <font size=\"-5\">left to</font> %2</font>").arg(ClientName).arg(newChannel));
    		// somewhere else
    		else
    			getController(serverConnectionHandlerID)->addChatLine(QString("<font size=\"-5\">%1 moved from %2 to %3</font>").arg(ClientName).arg(oldChannel).arg(newChannel));
    	}
    	else if (!ClientName.isEmpty() && oldChannel.isEmpty() && !newChannel.isEmpty())
    	{
    		getController(serverConnectionHandlerID)->addChatLine(QString("%1 <font size=\"-5\">connected to</font> %2").arg(ClientName).arg(newChannel));
    	}
    

    this does not work, too

    QString("<font size=\"-5\"><%1></font> %2").arg(fromName).arg(message)
    

    The result should be
    <name> MESSAGE
    But it does not work. I'm pretty sure it's because of the <> things. So is there a way that those are displayed and ignored from the html format if they are no keywords such as font??

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      The most easy way to check such stuff is using the HTML editor
      Place a QLabel on a form, right click it and Choose Change HTML
      alt text

      Then paste your generated html code in "source" and see what it dont like
      or Try to visually create what you want and check the HTML.

      1 Reply Last reply
      0
      • QT-static-prgmQ Offline
        QT-static-prgmQ Offline
        QT-static-prgm
        wrote on last edited by
        #3

        i could fix the chat thing with that using

        &lt;
        

        But it does not work if someone has <> in his nick name

        QString("%1 <font size=\"-5\">connected to</font> %2").arg(ClientName).arg(newChannel)
        

        Any ideas about that??

        QT-static-prgmQ 1 Reply Last reply
        0
        • QT-static-prgmQ QT-static-prgm

          i could fix the chat thing with that using

          &lt;
          

          But it does not work if someone has <> in his nick name

          QString("%1 <font size=\"-5\">connected to</font> %2").arg(ClientName).arg(newChannel)
          

          Any ideas about that??

          QT-static-prgmQ Offline
          QT-static-prgmQ Offline
          QT-static-prgm
          wrote on last edited by
          #4

          Man Qt is that GENIUS!!!

          QString QString::toHtmlEscaped() const

          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