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. Paginating a QTextEdit
Forum Updated to NodeBB v4.3 + New Features

Paginating a QTextEdit

Scheduled Pinned Locked Moved General and Desktop
15 Posts 6 Posters 9.1k Views 2 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #2

    Hi Icco,

    QTextEdit internally still uses the QTextDocument. There is a ready demo in Qt installation called TextEdit, that is a good place to start ...qt/demos/textedit

    Are you trying to show page separators?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      icco
      wrote on last edited by
      #3

      Yes, the main thing I am trying to do is show page separation in a QTextEdit. I'll check out that demo, thanks.

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #4

        If you want like the page layout in word, one way I see is ...
        using QGraphicsView, setting the scene, setting multiple QGraphicsTextItems which are editable, and updating the entire text on any edits.. you can set QTextDocument to these text items ..

        Something similar is also available if you refer the QPrintPreviewWidget source

        1 Reply Last reply
        0
        • I Offline
          I Offline
          icco
          wrote on last edited by
          #5

          Oh that is cool. Thanks.

          I'm finding the scene documentation kind of confusing. How do I create GraphicsItems in the correct places? Right now when I add things to the scene, they all just stack in the center. Then when I setPos, they get put in weird places.

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #6

            To learn QGraphicsView, a very good example is the chips demo that ships with Qt ...

            You create a QGraphicsView, then create a QGraphicsScene, create and add QGraphicsItems to the scene (text item, or pixmap item), set position and z order if required for each of these graphics items and set the scene to the view.. that's basically about it. Read up the API in the assistant for full set of capabilities ...

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #7

              Hi Icco,

              Could you perhaps show how you managed to solve this? On StackExchange you say you have something that works (linking to this topic), but I don't see an easy way to get each of the QGraphicsTextItems showing the right part of the document. Would be cool to see how this can be done.

              Thanks

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DOGG_11
                wrote on last edited by
                #8

                Hi Andre.

                Check my implementation of paginated QTextEdit https://github.com/dimkanovikov/PagesTextEdit

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

                  Hello. I read your post with your implentation of qtextedit which is layouted like word. I have question. How can i add Actions, menus and toolbars to the window? I think you can do this only with QMainWindow. Please help me, thanks. Henrik

                  mrjjM 1 Reply Last reply
                  0
                  • ? A Former User

                    Hello. I read your post with your implentation of qtextedit which is layouted like word. I have question. How can i add Actions, menus and toolbars to the window? I think you can do this only with QMainWindow. Please help me, thanks. Henrik

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @HenrikSt. said:

                    Hi and welcome

                    You can just insert his PagesTextEdit widget into a QMainwindow and have
                    menus and toolbar.

                    ? 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @HenrikSt. said:

                      Hi and welcome

                      You can just insert his PagesTextEdit widget into a QMainwindow and have
                      menus and toolbar.

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      How i can do that? Please leave a example. Thank you

                      mrjjM 1 Reply Last reply
                      0
                      • ? A Former User

                        How i can do that? Please leave a example. Thank you

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @HenrikSt.

                        hi
                        Make a new default Qt Gui project
                        includes the .cpp files and .h files for PagesTextEdit (copy to project folder)

                        Then in Mainwindow constructor ( ask if u dont know what constructor is)
                        you create it and place it as central

                        setCentralWidget( new PagesTextEdit )

                        You will need to know some c++ to get this working. :)

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

                          I can't follow since step 3. Then in mainwindow constructor.. where is it?

                          mrjjM 1 Reply Last reply
                          0
                          • ? A Former User

                            I can't follow since step 3. Then in mainwindow constructor.. where is it?

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            @HenrikSt.
                            in mainwindow.cpp

                            MainWindow::MainWindow(QWidget* parent) :
                            QMainWindow(parent),
                            ui(new Ui::MainWindow) {
                            ui->setupUi(this);
                            ---> your code here

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Pauly
                              wrote on last edited by Pauly
                              #15
                              This post is deleted!
                              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