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. QTextDocument Frames and Rendering
Forum Updated to NodeBB v4.3 + New Features

QTextDocument Frames and Rendering

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 2.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.
  • O Offline
    O Offline
    ofmrew
    wrote on last edited by
    #1

    I have read all the qt documentation on QTextEdit, QPlaintTextEdit, QTextDocument, QTextBlock, QTextCursor, QSyntaxHighlighter, etc. The documentation is strong on how to do something, but like nearly all documentation, it does not cover why you would do it; that is left to examples. I have questions regarding frames and how the renderers of QTextEdit andQPlaintTextEdit handle frames and rich-text.

    It appears to me that frames are used in both editors when it is necessary to change the formatting of some text blocks, e.g., say the case where a long citation is inserted, with indention on both sides and an italic font. Is there some document that goes into more detail on the use of frames in QPlainText documents?

    The second question relates to the rendering of documents. Because both QTextEdit and QPlainTextEdit are based on the QTextDocument and QTextCursor can insert both frames and rich-text, it would seem that I could insert frames and rich-text into a plain text document. Does the rendering code show the rich-text as plain text and ignore any frame that it cannot render?

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

      Hi,

      Can you show an example of what you would like to achieve ?

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

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you show an example of what you would like to achieve ?

        O Offline
        O Offline
        ofmrew
        wrote on last edited by
        #3

        @SGaist There is nothing in particular, I am just trying to understand the limitations. For example, it would seem that the only "frames" allowed in that QTextDcoument are text blocks, which can contain plain or rich-text, tables, lists and images. The QPlainTextEditor can only handle text blocks in the form of QStrings. The citation example was one I surmised could be handled by the formatting capability of the frame. The QTextEditor has all the capabilities of the QPlainTextEdit and adds rich-text. I was just wondering if I was missing something.

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

          QPlainTextEdit is optimised for "not-fancy" text rendering while QTextEdit is for rich text.

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

          O 1 Reply Last reply
          0
          • SGaistS SGaist

            QPlainTextEdit is optimised for "not-fancy" text rendering while QTextEdit is for rich text.

            O Offline
            O Offline
            ofmrew
            wrote on last edited by
            #5

            @SGaist I want to have plan text and display equations--in standard mathematical form.

            O 1 Reply Last reply
            0
            • O ofmrew

              @SGaist I want to have plan text and display equations--in standard mathematical form.

              O Offline
              O Offline
              ofmrew
              wrote on last edited by
              #6

              @ofmrew Allow me to expand on my response. If you are familiar with LaTeX, then you will understand my usage of inline and display math. I want to develop an editor that will combine plain text with LaTeX statements that will display when the source is compiled. The concept of using a frame to create an area, both within a text line and as a separate paragraph, where something other than plain text, and equation, is displayed is what I want, but I see no way of creating and displaying the contents of my frame. If creating my own frame and painter is not possible, then I will build it from scratch using QWidget and QPainter, but I hope I am missing something.

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

                So you would like to implement some sort of WYSIWYG LaTeX editor ?

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

                O 2 Replies Last reply
                0
                • SGaistS SGaist

                  So you would like to implement some sort of WYSIWYG LaTeX editor ?

                  O Offline
                  O Offline
                  ofmrew
                  wrote on last edited by
                  #8

                  @SGaist It is like that but more. LaTeX is for typesetting documents, especially those with mathematical expressions. I want the text and the subset of LaTeX to be compiled into executable code. Purpose: to provide a visual aid to the equations being used and not having to relying on interpreting the butchered programming language code--this would not only help the programmer, but all that follow doing maintenance.

                  QPlaintTextEdit and QTextEdit have many features that I would like to use. Right now I am exploring whether subclassing QFrame and QCursor will do what I want.

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    So you would like to implement some sort of WYSIWYG LaTeX editor ?

                    O Offline
                    O Offline
                    ofmrew
                    wrote on last edited by
                    #9

                    @SGaist I did some research and subclassing is a dead end. It appears that QTextEdit keeps a QTextDocument as a property, but QPlaintTextEdit keeps only a QString--I assume that the QTextDocument is created only when requested.

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

                      A quick look at the sources of QPlaintTextEdit shows that it uses a QTextDocument but with a custom QAbstractTextDocumentLayout.

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

                      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