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. I can't replace "<" to "&lt;"
Forum Updated to NodeBB v4.3 + New Features

I can't replace "<" to "&lt;"

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.9k 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.
  • BrikinhosB Offline
    BrikinhosB Offline
    Brikinhos
    wrote on last edited by
    #1

    It's simple

     QString text= "This is a message test < > < > > > < < < <<< >> jan<d>epora";
     text.replace("<","&lt;");
    

    It's doesn't work, but with "&l;" or other word it works. Is this a bug?

    Thanks in advance

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

      Hi,

      What do you mean by doesn't work ? What output are you expecting ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      BrikinhosB 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What do you mean by doesn't work ? What output are you expecting ?

        BrikinhosB Offline
        BrikinhosB Offline
        Brikinhos
        wrote on last edited by
        #3

        @SGaist Hi, i expect this output:

        "This is a message test &lt; > &lt; > > > &lt; &lt; &lt; &lt;&lt;&lt; >> jan&lt;d>epora";
        

        It's incredible, but it works replacing with other word.

        1 Reply Last reply
        0
        • BrikinhosB Offline
          BrikinhosB Offline
          Brikinhos
          wrote on last edited by Brikinhos
          #4

          @SGaist Ahhhh, damn, i know what is the $%&/ problem, i use this to test my program:

          QMessageBox::information(0,"Test",text);
          

          If i use:

          QMessageBox::information(0,"Test","&lt;");
          

          the output is "<"

          Damn, 3 hours for this, i hate and love Qt

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            Hi @Brikinhos ,

            @SGaist Ahhhh, damn, i know what is the $%&/ problem, i use this to test my program:

            This is documented in the QMessageBox class reference (see the section called "Rich Text and the Text Format Property").

            Anyway, I recommend converting with QString::toHtmlEscaped() and testing with qDebug():

            #include <QDebug>
            
            // ...
            
            QString text = "This is a message test < > < > > > < < < <<< >> jan<d>epora";
            qDebug() << text.toHtmlEscaped();
            

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            BrikinhosB 1 Reply Last reply
            1
            • JKSHJ JKSH

              Hi @Brikinhos ,

              @SGaist Ahhhh, damn, i know what is the $%&/ problem, i use this to test my program:

              This is documented in the QMessageBox class reference (see the section called "Rich Text and the Text Format Property").

              Anyway, I recommend converting with QString::toHtmlEscaped() and testing with qDebug():

              #include <QDebug>
              
              // ...
              
              QString text = "This is a message test < > < > > > < < < <<< >> jan<d>epora";
              qDebug() << text.toHtmlEscaped();
              
              BrikinhosB Offline
              BrikinhosB Offline
              Brikinhos
              wrote on last edited by
              #6

              @JKSH Thank you very much, it works with qDebug()

              1 Reply Last reply
              0

              • Login

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