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. Hidden information in a QTextDocument
Qt 6.11 is out! See what's new in the release blog

Hidden information in a QTextDocument

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 4.8k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello, I need to embed some information in a QTextDocument but it has to be hidden. A QTextEdit doesn't have to show that information but it is only for my program purpose.
    I saw there are MetaInformation but there are only two values, url and title. I need more and different values.
    I think to make a fragment or a block hidden but I fear that user can edit above it or change its position so I can't get it anymore.

    Has someone some suggest form me?
    Best Regards
    Willy

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Maybe you can create your own class that inherits QTextDocument, something like this:
      @class MyEditor : public QTextDocument{
      Q_OBJECT
      public:
      MyEditor(QWidget *parent = 0);
      QString get_info();
      void set_info(const QString &info);
      private:
      QString info;
      };@

      1 Reply Last reply
      0
      • N Offline
        N Offline
        ngrosjean
        wrote on last edited by
        #3

        You could just create a class that inherit QTextDocument, then use it. In your sub class just add a QString and do what you want with it.
        Another solution on your subclass is to play with http://doc.trolltech.com/4.6.2/qobject.html#Q_PROPERTY and other Q_... macro.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Interesting ideas, some idea to store and retrieve info on and from same document's file?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            why not just use QObject::setProperty function

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              My problem is storing and retrieving information from file on disk.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                There are no means to leave comments or hidden text in a text document. You would have to subclass QTextDocument and/or QTextEdit an put that information into the output generated by that manually. You will have to parse it out of a to-be-set document manually too, as QTextDocument discards all data it is not supposed to use (ie. feeding your manually crafted text into a regular QTextDocument "cleans" out all the added data).

                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