How to modificate size of QPlainTextEdit
-
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 ;)
-
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
-
Or should it be setMaximumSizeHint
-
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.
-
BlankDante
Can you have look at this : "Differencies to QTextEdit":http://doc.qt.nokia.com/4.7-snapshot/qplaintextedit.html#differences-to-qtextedit
-
[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 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.
-
[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()
-
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.
-
[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.
-
[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.
-
Thanks for yours help :) it was very helpful :)
-
[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).
-
[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 :-)