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. [SOLVED!] Build a single widget from source
Forum Updated to NodeBB v4.3 + New Features

[SOLVED!] Build a single widget from source

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 3.1k 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.
  • J Offline
    J Offline
    Jan-Willem
    wrote on last edited by
    #1

    Hi there,

    While thinking about my question as original posted, I concluded that the question could be asked a lot simpler. So here it is.

    I am trying to build QTextEdit from source. I have taken the source files including private headers, renamed them (removed the Q at the beginning) and tried to build it as is, but so far no luck. For every change I make, various new problems pop up.

    Is it possible to build just a single widget from source (in my case QTextEdit)?

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

      Hi,

      It really depends on the widget and QTextEdit is not the most simple to take apart.

      In what way do you want to extend it ?

      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
      • J Offline
        J Offline
        Jan-Willem
        wrote on last edited by
        #3

        I want to make som changes in the QTextHtmlParser class, which is a private class of QTextDocument. And offcourse the result should be visible/editable in (a custom) QTextEdit.

        I figured that changing QTextDocument would also affect QTextEdit.

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

          Then rather keep the discussion on only one thread since this one will duplicate that "one":http://qt-project.org/forums/viewthread/53180/

          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
          • J Offline
            J Offline
            Jan-Willem
            wrote on last edited by
            #5

            Just closed that one.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jan-Willem
              wrote on last edited by
              #6

              Yesterday I decided to make a new start with QTextDocument, hence the "other":http://qt-project.org/forums/viewthread/53180/ topic. Taking the source files of QTextDocument and adding all other as needed. Renaming (removing the Q) the classes turned out to be a lot of work.

              Now I am facing the following error:
              @'QExplicitlySharedDataPointer<QFontPrivate> QFont::d' is private
              QExplicitlySharedDataPointer<QFontPrivate> d;
              ^@

              Changing the QFont class doens't seem smart to do, because the further I go the less I can make use of the standard stuff.

              Any advice on where to go from here?

              1 Reply Last reply
              0
              • J Offline
                J Offline
                Jan-Willem
                wrote on last edited by
                #7

                For now I have taken a slight different apporach, since everything I have done so far just ends with not being able to use QFont etc.

                From what I have learned so far, the way QTextDocument translates html into somting readable, I am able to create a different parser and add it to an subclass of QTextDocument.

                Since SGaist has said that QTextedit is not the easiest to take apart, should I better write an new editor? Painting the contents of a QTextDocument on an widget is something I have done before. But how to make it editable? Reading trough all the code has been a bit overwhelming.

                Perhaps some insight on that?

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

                  Did you try to just "Clone" QTextDocument and just modify its name and the one from the private implementation but leave the rest Qt ?

                  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
                  • J Offline
                    J Offline
                    Jan-Willem
                    wrote on last edited by
                    #9

                    Thats how I started. I changed the name of the file (qtextdocument.h to textdocument.h etc.) and of the class, QTextDocument and QTextDocumentPrivate to TextDocument and TextDoxumentPrivate.

                    But then I ran in trouble, because QTextBlock, QTextCursor and so on expect a QTextDocument and not a TextDocument. So I started working on them too.

                    Perhaps that was a bit to enthousiastic.

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      Jan-Willem
                      wrote on last edited by
                      #10

                      I gave it another try, but I stumble upon the same problem. When I created a demoproject with the htmlparser (see earlier post), I was able to exclude the private headers from other classes in the html parser without any big problems.

                      This approach doesn't work with QTextDocument, since QTextDocumentPrivate is also used in QTextCursor and QTextObject. And QTextDocument is used in a lot more classes.

                      I have tried it with a static_cast which did not work. Besides, since the private headers are not part of the Qt API, this would not be an everlasting solution I think.

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

                        Looks like you would have less problems modifying Qt for your purpose...

                        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
                        • J Offline
                          J Offline
                          Jan-Willem
                          wrote on last edited by
                          #12

                          If you mean by modifying subclassing and adding functionality, then you are absolutely right. But it isn't only about functionality, but also about performance.
                          When I can build an editor with a custom document, I can also tailor it to fit it's primary task and thus making it more efficiƫnt. For example like QCodeEditor.

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            Jan-Willem
                            wrote on last edited by
                            #13

                            Well, although I am far from finished, I seem to have found the trick.

                            As sugested by SGaist I have "cloned" QTextDocument and the one from the private implementation.

                            I have added core-private and gui-private to the .pro file for the time being. These will be deleted if all is finished.
                            Next I have copied QTextHtmlParser and added is to the project as a class and created a HtmlImporter class after which the private header of QtextDocumentFragment can be excluded.

                            This is working, so now to the next private headers...

                            I guess this makes this thread solved.

                            Thank you SGaist for your suggestions.

                            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