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 use both the properties of Qtextdocument
Forum Updated to NodeBB v4.3 + New Features

How to use both the properties of Qtextdocument

Scheduled Pinned Locked Moved Unsolved General and Desktop
33 Posts 3 Posters 6.2k 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.
  • ManiRonM ManiRon

    @VRonin i tried the same way as yours (QTextCursor cursor(textDocument);) but it says

    mainwindow.cpp:107: error: 'textDocument' was not declared in this scope
    QTextCursor cursor(textDocument);
    ^

    VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #16

    @ManiRon The title of your post is "How to use both the properties of Qtextdocument" I assumed you have a QTextdocument to work on. maybe ui->teData->document()?

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • ManiRonM ManiRon

      @JonB I agree with u sir. But i am in a situation that i require to use both . Thats why keep on asking about it. Dont Mistake.0_1534921806909_4.JPG . It shows like this.

      ManiRonM Offline
      ManiRonM Offline
      ManiRon
      wrote on last edited by
      #17

      @ManiRon 0_1534921905213_5.JPG

      1 Reply Last reply
      0
      • ManiRonM ManiRon

        @VRonin i tried the same way as yours (QTextCursor cursor(textDocument);) but it says

        mainwindow.cpp:107: error: 'textDocument' was not declared in this scope
        QTextCursor cursor(textDocument);
        ^

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #18

        @ManiRon said in How to use both the properties of Qtextdocument:

        @VRonin i tried the same way as yours (QTextCursor cursor(textDocument);) but it says

        mainwindow.cpp:107: error: 'textDocument' was not declared in this scope
        QTextCursor cursor(textDocument);
        ^

        The error message tells you exactly what is wrong with your code, nothing to add by showing screenshots. You cannot expect to copy @VRonin's suggestion verbatim without any attempt to understand what it is doing and what you need to do to complete it. Why don't you have a look in the docs at QTextCursor's constructors? He wants you to understand what is wrong and deal with it, for your own long-term benefit.

        ManiRonM 1 Reply Last reply
        2
        • JonBJ JonB

          @ManiRon said in How to use both the properties of Qtextdocument:

          @VRonin i tried the same way as yours (QTextCursor cursor(textDocument);) but it says

          mainwindow.cpp:107: error: 'textDocument' was not declared in this scope
          QTextCursor cursor(textDocument);
          ^

          The error message tells you exactly what is wrong with your code, nothing to add by showing screenshots. You cannot expect to copy @VRonin's suggestion verbatim without any attempt to understand what it is doing and what you need to do to complete it. Why don't you have a look in the docs at QTextCursor's constructors? He wants you to understand what is wrong and deal with it, for your own long-term benefit.

          ManiRonM Offline
          ManiRonM Offline
          ManiRon
          wrote on last edited by
          #19

          @JonB Yes sir i am getting that i cannot use both at the same time and i tried with a sample code too.

          1 Reply Last reply
          0
          • ManiRonM ManiRon

            @JonB header has top left corner one image and top right corner one image and a title at the middle of the two images, and after that i want insert my texts. This much things i want to do . Is there any way ? :(

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #20

            @ManiRon said in How to use both the properties of Qtextdocument:

            @JonB header has top left corner one image and top right corner one image and a title at the middle of the two images, and after that i want insert my texts. This much things i want to do . Is there any way ? :(

            Assuming this has nothing to do with PDF (sometimes you talk about the PDF header or "inserting PDF", I'm never sure), this sounds like you want to insert an image into your document? Have a read of http://doc.qt.io/qt-5/richtext-cursor.html and http://doc.qt.io/qt-5/qtextcursor.html#insertImage-2 ? I really think you need to do some reading of this sort of stuff to get an idea of what you can do with QTextDocument & QTextCursor.

            ManiRonM 2 Replies Last reply
            1
            • JonBJ JonB

              @ManiRon said in How to use both the properties of Qtextdocument:

              @JonB header has top left corner one image and top right corner one image and a title at the middle of the two images, and after that i want insert my texts. This much things i want to do . Is there any way ? :(

              Assuming this has nothing to do with PDF (sometimes you talk about the PDF header or "inserting PDF", I'm never sure), this sounds like you want to insert an image into your document? Have a read of http://doc.qt.io/qt-5/richtext-cursor.html and http://doc.qt.io/qt-5/qtextcursor.html#insertImage-2 ? I really think you need to do some reading of this sort of stuff to get an idea of what you can do with QTextDocument & QTextCursor.

              ManiRonM Offline
              ManiRonM Offline
              ManiRon
              wrote on last edited by
              #21

              @JonB Yes sir sure. I have another doubt . Is there any possibility that i can add my image as the header of the pdf document which want to create.

              1 Reply Last reply
              0
              • JonBJ JonB

                @ManiRon said in How to use both the properties of Qtextdocument:

                @JonB header has top left corner one image and top right corner one image and a title at the middle of the two images, and after that i want insert my texts. This much things i want to do . Is there any way ? :(

                Assuming this has nothing to do with PDF (sometimes you talk about the PDF header or "inserting PDF", I'm never sure), this sounds like you want to insert an image into your document? Have a read of http://doc.qt.io/qt-5/richtext-cursor.html and http://doc.qt.io/qt-5/qtextcursor.html#insertImage-2 ? I really think you need to do some reading of this sort of stuff to get an idea of what you can do with QTextDocument & QTextCursor.

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #22

                @JonB Its just a title where i want to place my company logo on the left and right top corner and the titke as my project .

                JonBJ 1 Reply Last reply
                0
                • ManiRonM ManiRon

                  @JonB Its just a title where i want to place my company logo on the left and right top corner and the titke as my project .

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #23

                  @ManiRon
                  Not via QTextDocument. You'd have to look at manipulating the PDF output, which is a different matter.

                  Something like https://forum.qt.io/topic/74643/qtextdocument-to-pdf-with-watermarks-and-header-footer-filesize-too-large might give you some ideas. I do not guarantee whether that is good/the right approach, but it might be.

                  ManiRonM 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @ManiRon
                    Not via QTextDocument. You'd have to look at manipulating the PDF output, which is a different matter.

                    Something like https://forum.qt.io/topic/74643/qtextdocument-to-pdf-with-watermarks-and-header-footer-filesize-too-large might give you some ideas. I do not guarantee whether that is good/the right approach, but it might be.

                    ManiRonM Offline
                    ManiRonM Offline
                    ManiRon
                    wrote on last edited by
                    #24

                    @JonB 0_1534923312690_Report.png

                    ManiRonM 1 Reply Last reply
                    0
                    • ManiRonM ManiRon

                      @JonB 0_1534923312690_Report.png

                      ManiRonM Offline
                      ManiRonM Offline
                      ManiRon
                      wrote on last edited by
                      #25

                      @ManiRon This is my report with an example image inserted. the two images with the Name REPORT are the title of the document and that "sdvzfdvzsfdv" is the text that i wanted to insert.

                      JonBJ 1 Reply Last reply
                      0
                      • ManiRonM ManiRon

                        @ManiRon This is my report with an example image inserted. the two images with the Name REPORT are the title of the document and that "sdvzfdvzsfdv" is the text that i wanted to insert.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #26

                        @ManiRon
                        If you don't want to do this via the paint() suggested in the link I posted above, you could try with either QTextCursor::insertImage() or you could try writing the whole thing in HTML and seeing if QTextCursor::insertHtml() accepts it or not, I don't know.

                        ManiRonM 2 Replies Last reply
                        1
                        • JonBJ JonB

                          @ManiRon
                          If you don't want to do this via the paint() suggested in the link I posted above, you could try with either QTextCursor::insertImage() or you could try writing the whole thing in HTML and seeing if QTextCursor::insertHtml() accepts it or not, I don't know.

                          ManiRonM Offline
                          ManiRonM Offline
                          ManiRon
                          wrote on last edited by
                          #27

                          @JonB Ok Sir . i will read about it and check with an example code.

                          1 Reply Last reply
                          0
                          • JonBJ JonB

                            @ManiRon
                            If you don't want to do this via the paint() suggested in the link I posted above, you could try with either QTextCursor::insertImage() or you could try writing the whole thing in HTML and seeing if QTextCursor::insertHtml() accepts it or not, I don't know.

                            ManiRonM Offline
                            ManiRonM Offline
                            ManiRon
                            wrote on last edited by
                            #28

                            @JonB but with this QTextCursor::insertImage() property whether i can place the image anywhere ?

                            JonBJ 1 Reply Last reply
                            0
                            • ManiRonM ManiRon

                              @JonB but with this QTextCursor::insertImage() property whether i can place the image anywhere ?

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #29

                              @ManiRon
                              You can insert it wherever you can navigate a QTextCursor to. Frankly I don't understand from what you have written where exactly it is you want it, so I don't know whether you can navigate there.

                              ManiRonM 1 Reply Last reply
                              1
                              • JonBJ JonB

                                @ManiRon
                                You can insert it wherever you can navigate a QTextCursor to. Frankly I don't understand from what you have written where exactly it is you want it, so I don't know whether you can navigate there.

                                ManiRonM Offline
                                ManiRonM Offline
                                ManiRon
                                wrote on last edited by
                                #30

                                @JonB I want it to be in the header section of a PDF file.
                                example: <Image> TITLE <Image>

                                JonBJ 1 Reply Last reply
                                0
                                • ManiRonM ManiRon

                                  @JonB I want it to be in the header section of a PDF file.
                                  example: <Image> TITLE <Image>

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #31

                                  @ManiRon
                                  Then like I said you can't, unless you want to work on getting at the PDF from the QTextDocument before it gets sent to the printer and manipulate it from there.

                                  ManiRonM 1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @ManiRon
                                    Then like I said you can't, unless you want to work on getting at the PDF from the QTextDocument before it gets sent to the printer and manipulate it from there.

                                    ManiRonM Offline
                                    ManiRonM Offline
                                    ManiRon
                                    wrote on last edited by ManiRon
                                    #32

                                    @JonB will there be any possibility or any idea because i am out of idea

                                    JonBJ 1 Reply Last reply
                                    0
                                    • ManiRonM ManiRon

                                      @JonB will there be any possibility or any idea because i am out of idea

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #33

                                      @ManiRon
                                      As I said, you will have to look, I think, at: instead of making the QTextDocument send the PDF it can produce straight to the printer without change, rather you must "intercept" it and do whatever you need to the PDF header first.

                                      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