Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Solved When QTextEdit will understand tag <strike>?

    General and Desktop
    3
    9
    1847
    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.
    • S
      sersver00 last edited by

      Qt5.5, 5.6, 5.7 don't undersand tag <strike> in QTextEdit, but they understand tag <s>

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @sersver00 last edited by

        @sersver00
        the supported HTML subset can be viewed here.
        Nevertheless you should ask this question on the developer mailing list.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        S 1 Reply Last reply Reply Quote 5
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          Hi
          Most likely never as
          "<strike> has been deprecated in HTML 4 and XHTML 1, and obsoleted in HTML5. If semantically appropriate, i.e., if it represents deleted content, use the <del> instead; in all other cases use an <s> element."

          S 1 Reply Last reply Reply Quote 6
          • S
            sersver00 @raven-worx last edited by

            @raven-worx Thank you very much.

            raven-worx 1 Reply Last reply Reply Quote 0
            • S
              sersver00 @mrjj last edited by

              @mrjj Ok, but QTextEdit may paste Rich HTML text. I only copy text from last version of Firefox and the text contains <strike>. I paste the text to QTextEdit and see ordinar text. :( I think, the tag <strike> is still need.

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @sersver00 last edited by mrjj

                @sersver00 said in When QTextEdit will understand tag <strike>?:

                I paste the text to QTextEdit and see ordinar text

                But does pasting bold text and other stuff works?
                Maybe it strips all HTML ?
                (Dont have a QTextEdit to test with right now :)

                S 1 Reply Last reply Reply Quote 2
                • S
                  sersver00 @mrjj last edited by

                  @mrjj I test the text with the tag in standard example from qt packet too. As described here <strike> is not support now. My way is the developer mailing list. I see no other way out.
                  Thanks!

                  1 Reply Last reply Reply Quote 0
                  • raven-worx
                    raven-worx Moderators @sersver00 last edited by VRonin

                    @sersver00
                    Here's a little workaround:

                    void MyTextEdit::insertFromMimeData(const QMimeData *mimeData)
                    {
                          QMimeData mimeDataCopy;
                    
                          // duplicate mimeData
                          foreach( QString format, mimeData.formats() )
                          {
                                 QByteArray data = mimeData->data(format);
                                 if( format.startsWith( QLatin1String("text/html"), Qt::CaseInsensitive )
                                 {
                                           data.replace(QByteArray("<strike>"), QByteArray("<s>"));
                                           data.replace(QByteArray("</strike>"), QByteArray("</s>"));
                                 }
                                 mimeDataCopy.setData( format,  data );
                           }
                    
                          QTextEdit::insertFromMimeData( &mimeDataCopy );
                    }
                    

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    S 1 Reply Last reply Reply Quote 3
                    • S
                      sersver00 @raven-worx last edited by sersver00

                      @raven-worx Thank you. Your idea works.
                      The question is solved

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