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 660 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.
  • HansonH Offline
    HansonH Offline
    Hanson
    wrote on 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

    JonBJ 1 Reply Last reply
    0
    • HansonH Hanson

      @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.

      HansonH Offline
      HansonH Offline
      Hanson
      wrote on 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
      • HansonH Hanson

        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!

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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?

        HansonH 1 Reply Last reply
        0
        • JonBJ JonB

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

          HansonH Offline
          HansonH Offline
          Hanson
          wrote on 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

          JonBJ 1 Reply Last reply
          0
          • HansonH Hanson

            @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.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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
            • HansonH Offline
              HansonH Offline
              Hanson
              wrote on 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

              HansonH 1 Reply Last reply
              0
              • HansonH Hanson

                @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.

                HansonH Offline
                HansonH Offline
                Hanson
                wrote on 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
                • HansonH Hanson has marked this topic as solved on

                • Login

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