You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Sunday, September 5th 2010, 10:01pm

Keeping a QTextEdit aligned with window while resizinjg a window.

I've looked and looked, at all the exanples in QT, I still do not understand how you keep the QTextEdit to stay the same as my window, even if I maximized it, how would I set that in code if I have this as my variable??

Source code

    QTextEdit *textEdit;


Sunday, September 5th 2010, 11:33pm

If you meant "how to automatically resize the QTextEdit when its parent window is resized", you have to set a layout (QVBoxLayout/QHBoxLayout or QGridLayout) in the parent widget and add your QTextEdit inside it.
QMainWindow already contains a layout, so if the window is of that type, you have to use QMainWindow::setCentralWidget instead (same thing for QMdiWindow and setWidget).


Thursday, September 23rd 2010, 9:12am

No no. I meant, when you resize the main window, the Text Edit widget stays the same, the main window won't wrap over it, and buttons too, I'd like to make my button on my Options window stay aligned with the bottom, even if somebody resized the main Options Window.


Thursday, September 23rd 2010, 10:29am

Sorry, but I still don't understand what you mean. Could you maybe post a screenshot of what you want or don't want ?


Thursday, September 23rd 2010, 11:17am

LOL, sorry, never mind.. I can't explain it any other way.. still learning QT, it's just when the user resizes the main window, my textEdit Widget is supposed to stay the same size as the main window, even when resizing.. I tried using QT Creator to try this example, but it doesn't have anything in the QVHBoxLayout or whatever, to keep it the same size as the Main Window.. I even put a QTextEdit Widget inside of it.. the Main Window still over laps, even the Layout.


Thursday, September 23rd 2010, 1:42pm

In the designer, you have to add your QTextEdit to the main window, then right-click on the main window and choose a layout from the contextual menu. That part of the menu is not enabled until you add a widget to be laid out.


Thursday, September 23rd 2010, 2:46pm

LOL, that's the issue.. I've been hand coding it.. I'd rather hand code, than use the Creator.. This was a while ago, I've rewritten it since.. I like to delete start over, to keep my memory fresh on the codes, if I go a week without doing it. I forget... My memory isn't so good anymore, not sure why.


Thursday, September 23rd 2010, 7:30pm

This post can be removed.. The issue is resolved.. All I had to do was set my myTextEdit as central widget, as the one usre described.. Thanks, =).