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. How to extract the text of custom text object format in QTextEdit
Forum Updated to NodeBB v4.3 + New Features

How to extract the text of custom text object format in QTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 622 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
    Hanson
    wrote on 23 May 2023, 08:39 last edited by
    #1

    I hava created a custom text object class derived from QTextObjectInterface.And I want to use QTextEdit::toPlainText to export the text.
    Any help is appreciated!

    “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
    —— Martin Golding

    J 1 Reply Last reply 23 May 2023, 09:12
    0
    • H Hanson
      23 May 2023, 13:05

      @JonB Emm,I use QTextObjectInterface is aim to show my own custom text object, and use the string property to control how to paint the object.Also i want to export the string to other using.

      H Offline
      H Offline
      Hanson
      wrote on 25 May 2023, 00:56 last edited by
      #6

      @Hanson Finally,I find a way to traverse QTextDocument in QTextEdit,and extract all data I want,include the normal text and my custom text object.
      80cc8681-eb89-4058-8128-f37a16c2fc7b-image.png

      “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
      —— Martin Golding

      1 Reply Last reply
      0
      • H Hanson
        23 May 2023, 08:39

        I hava created a custom text object class derived from QTextObjectInterface.And I want to use QTextEdit::toPlainText to export the text.
        Any help is appreciated!

        J Offline
        J Offline
        JonB
        wrote on 23 May 2023, 09:12 last edited by
        #2

        @Hanson
        If you have a QTextObjectInterface to allow drawing of something (right?), what do you expect the output to be for QTextEdit::toPlainText?

        H 1 Reply Last reply 23 May 2023, 09:39
        0
        • J JonB
          23 May 2023, 09:12

          @Hanson
          If you have a QTextObjectInterface to allow drawing of something (right?), what do you expect the output to be for QTextEdit::toPlainText?

          H Offline
          H Offline
          Hanson
          wrote on 23 May 2023, 09:39 last edited by
          #3

          @JonB I set the string property of the custom text object, like this
          184ca897-1036-4ee7-a9ea-857aad352ff9-image.png
          And I want to export the string property.Or you have other method that can export this string.

          “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
          —— Martin Golding

          J 1 Reply Last reply 23 May 2023, 10:12
          0
          • H Hanson
            23 May 2023, 09:39

            @JonB I set the string property of the custom text object, like this
            184ca897-1036-4ee7-a9ea-857aad352ff9-image.png
            And I want to export the string property.Or you have other method that can export this string.

            J Offline
            J Offline
            JonB
            wrote on 23 May 2023, 10:12 last edited by
            #4

            @Hanson
            Hmm, never used QTextObjectInterface. The only documentation I can see for its text is the cryptic/terse:

            The data of a text object is usually stored in the QTextCharFormat using QTextCharFormat::setProperty(), and then retrieved with QTextCharFormat::property().

            But I don't know if that has any relationship to how you would get that out into QTextEdit::toPlainText() :(

            If you/someone else cannot find any way to do this, I can only think you might copy the whole of the QTextDocument, replace your QTextObjectInterface node(s) with their plain text, and then export that document. Not nice, but....

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hanson
              wrote on 23 May 2023, 13:05 last edited by
              #5

              @JonB Emm,I use QTextObjectInterface is aim to show my own custom text object, and use the string property to control how to paint the object.Also i want to export the string to other using.

              “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
              —— Martin Golding

              H 1 Reply Last reply 25 May 2023, 00:56
              0
              • H Hanson
                23 May 2023, 13:05

                @JonB Emm,I use QTextObjectInterface is aim to show my own custom text object, and use the string property to control how to paint the object.Also i want to export the string to other using.

                H Offline
                H Offline
                Hanson
                wrote on 25 May 2023, 00:56 last edited by
                #6

                @Hanson Finally,I find a way to traverse QTextDocument in QTextEdit,and extract all data I want,include the normal text and my custom text object.
                80cc8681-eb89-4058-8128-f37a16c2fc7b-image.png

                “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
                —— Martin Golding

                1 Reply Last reply
                0
                • H Hanson has marked this topic as solved on 25 May 2023, 00:56

                1/6

                23 May 2023, 08:39

                • Login

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