QTextEdit not Expanding

  • In Windows 7 64bit, using QtCreator 3.0.1 with Qt 5.2.1 I have a MainWindow with nothing inside but a QTextEdit widget, I am using a Grid Layout. When I test the window with the preview function (Alt+Shift-R) the text widget expands and shrinks with the MainWindow as it should, but when I run the app, the same text widget expands no more than a certain size while the MainWindow keeps expanding. I tried sizePolicies (Preferred,Preferred) and (Expanding, Expending) but they don't make a difference. There is no code that manipulates size policies or window sizes in the app.

    What could i be doing wrong or missing, any help is appreciated.

  • It is not possible to fin out what's wrong without seeing any code/ui but make sure that the maximum width/height of QTextEdit is not set to values less that than your screen's width/height.

    If you can, create a sample project that reproduces your issue and upload it somewhere so that people here can take a look.

  • Ok, I will do that, thanks, and by the way the min/max width/height are at their default values (0x0) and (16777215x16777215)

  • I think I located the source of the problem. In mycode I am using:


    to handle mouse events, does this require me to also handle resize events manually?

  • I found the solution. I needed to add the following code in MainWindow::eventFilter. Now the textEdit widget resizes properly.

    @ if (event->type() == QEvent::Resize) {
    return false;

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.