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 modificate size of QPlainTextEdit
Forum Updated to NodeBB v4.3 + New Features

How to modificate size of QPlainTextEdit

Scheduled Pinned Locked Moved General and Desktop
15 Posts 7 Posters 18.4k 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.
  • B Offline
    B Offline
    BlackDante
    wrote on last edited by
    #1

    Hi, this is my first post on forum so I want to say "Hello" to all of you :)
    I'm just started working witch Qt and I have a little problem.
    I don't know How change size of QPlainTextEdit, now in my code i have something like this:

    @QPlainTextEdit *textedit = new QPlainTextEdit(this);
    setCentralWidget(textedit);@

    and this gave mi a full screen of QPlainTextEdit, but i want to have only 3/4 screen fill with that object. Can someone explain me how to do that?

    PS. Sorry for my english, I have hope that you can understand me ;)

    sorry for my broken english :)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      milot.shala
      wrote on last edited by
      #2

      Hi BlackDante and welcome to the forums.

      I think if you want to use the QMainWindow, you should inherit a class from "QWidget":http://doc.qt.nokia.com/stable/qwidget.html#details, create objects inside it and apply a "layouts":http://doc.trolltech.com/4.7/layout.html there then instantiate your newly created QWidget-derived class then use setCentralWidget() function to make it as a central widget.

      On the other hand you could only use "QWidget":http://doc.qt.nokia.com/stable/qwidget.html#details alone which will act as a Window. Read more about QWidget "here.":http://doc.qt.nokia.com/stable/qwidget.html#details

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vcsala
        wrote on last edited by
        #3

        setMinimumSizeHint should work.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kamalakshantv
          wrote on last edited by
          #4

          Or should it be setMaximumSizeHint

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            VCSala, QtK: both do not work as the textedit always takes the complete space of the central area of the main widget. The best approach would be a widget, with layout and "stretch factors":http://doc.qt.nokia.com/stable/qwidget.html#sizePolicy-prop set correctly.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qtrahul
              wrote on last edited by
              #6

              BlankDante

              Can you have look at this : "Differencies to QTextEdit":http://doc.qt.nokia.com/4.7-snapshot/qplaintextedit.html#differences-to-qtextedit

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                [quote author="qtrahul" date="1293546514"]BlankDante

                Can you have look at this : "Differencies to QTextEdit":http://doc.qt.nokia.com/4.7-snapshot/qplaintextedit.html#differences-to-qtextedit[/quote]

                That is in no means related to the original problem.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kamalakshantv
                  wrote on last edited by
                  #8

                  [quote author="Volker" date="1293546759"][quote author="qtrahul" date="1293546514"]BlankDante

                  Can you have look at this : "Differencies to QTextEdit":http://doc.qt.nokia.com/4.7-snapshot/qplaintextedit.html#differences-to-qtextedit[/quote]

                  That is in no means related to the original problem.[/quote]

                  Most of the time Rahul refers to something unrelated.

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    Immii
                    wrote on last edited by
                    #9

                    [quote author="BlackDante" date="1293536403"]Hi, this is my first post on forum so I want to say "Hello" to all of you :)
                    I'm just started working witch Qt and I have a little problem.
                    I don't know How change size of QPlainTextEdit, now in my code i have something like this:

                    @QPlainTextEdit *textedit = new QPlainTextEdit(this);
                    setCentralWidget(textedit);@

                    and this gave mi a full screen of QPlainTextEdit, but i want to have only 3/4 screen fill with that object. Can someone explain me how to do that?

                    PS. Sorry for my english, I have hope that you can understand me ;) [/quote]

                    There are many ways you can do it you can set maximumsize or you can re implement sizeHint() function but in this case you will have to inherit your QtextEdit and return your desired size in sizeHint()

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      Guys, did you really read the OP?

                      setCentralWidget() is of QMainWindow. You can set whatever sizeHints or min or max sizes you want. The text edit will always occupy the complete area reserved for the central widget. At best it will resize the whole main window as such. But it will NOT change the amount of the central widget area that is covered by the text edit.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        qtrahul
                        wrote on last edited by
                        #11

                        [quote author="Volker" date="1293546759"][quote author="qtrahul" date="1293546514"]BlankDante

                        Can you have look at this : "Differencies to QTextEdit":http://doc.qt.nokia.com/4.7-snapshot/qplaintextedit.html#differences-to-qtextedit[/quote]

                        That is in no means related to the original problem.[/quote]

                        The original thread starter doesn't know about the class QPlainTextEdit in detail.

                        That is why I directed him to the class reference link.

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on last edited by
                          #12

                          [quote author="qtrahul" date="1293554245"]The original thread starter doesn't know about the class QPlainTextEdit in detail.

                          That is why I directed him to the class reference link.[/quote]

                          And you did not understand his/her problem as it's completely unrelated to QPlainTextEdit. It's a problem in the domain of QMainWindow (as for setCentralWidget) and of how any QWidget is placed in its central area. Take whatever QWidget based class as you want and you will have the same effect. The API docs of QPlainTextEdit do not help in any way.

                          No need to spit off some links on a class name in the OP like a "Pavlov's Dog":http://en.wikipedia.org/wiki/Pavlov’s_Dog if you did not understand the problem.

                          Sorry for beeing a bit rude here, but it does not help the OP if we put him on the wrong path.

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          1 Reply Last reply
                          0
                          • B Offline
                            B Offline
                            BlackDante
                            wrote on last edited by
                            #13

                            Thanks for yours help :) it was very helpful :)

                            sorry for my broken english :)

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              vcsala
                              wrote on last edited by
                              #14

                              [quote author="Volker" date="1293554683"][quote author="qtrahul" date="1293554245"]The original thread starter doesn't know about the class QPlainTextEdit in detail.

                              That is why I directed him to the class reference link.[/quote]

                              And you did not understand his/her problem as it's completely unrelated to QPlainTextEdit. It's a problem in the domain of QMainWindow (as for setCentralWidget) and of how any QWidget is placed in its central area. Take whatever QWidget based class as you want and you will have the same effect. The API docs of QPlainTextEdit do not help in any way.

                              No need to spit off some links on a class name in the OP like a "Pavlov's Dog":http://en.wikipedia.org/wiki/Pavlov’s_Dog if you did not understand the problem.

                              Sorry for beeing a bit rude here, but it does not help the OP if we put him on the wrong path. [/quote]

                              Volker, thanks for sharing your experience, unfortunately I have not faced this problem before, I have just used my known heuristics (first I would try the same if I have to solve the same problem in my application).

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on last edited by
                                #15

                                [quote author="VCsala" date="1293567419"]Volker, thanks for sharing your experience, unfortunately I have not faced this problem before, I have just used my known heuristics (first I would try the same if I have to solve the same problem in my application).[/quote]

                                No problem, setMinimumSizeHint at least has something to do with sizes of widgets :-)

                                http://www.catb.org/~esr/faqs/smart-questions.html

                                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