Qt formlayout not expanding qplaintextedit vertically
Question: I'm confused why a **QPlainTextEdit** widget will not resize vertically when
added to a **QFormLayout**. In the code below the text field correctly scales
up horizontally, but does not scale up vertically.

Can anyone explain this behavior and offer a solution? I've tried all the
tricks I know to no avail.

    
    
    from PyQt4 import QtGui
    
    class Diag(QtGui.QDialog):
    
        def __init__(self, parent, *args, **kwargs):
            QtGui.QDialog.__init__(self, parent)
            layout = QtGui.QFormLayout(self)
            widg = QtGui.QPlainTextEdit(self)
            layout.addRow('Entry', widg)
    
    if __name__ == '__main__': #pragma: no cover
        app = QtGui.QApplication([])
        window = Diag(None)
        window.show()
        app.exec_()
    

Here is an example of the QPlainTextEdit widget not resizing vertically:
![QPlainTextEdit added to QFormLayout but not resizing
vertically](http://s9.postimage.org/ejvmp1wtr/qplaintextedit_in_qformlayout_not_resize.jpg)

This is on Windows 7 using PyQt 4.5.2 and Python 32-bit 2.6.

Thanks.


Answer: It seems that, by default, a `QFormLayout` will only resize the height of its
fields according to their `sizeHint`.

To change this behaviour, adjust the [vertical
stretch](http://doc.qt.nokia.com/4.8-snapshot/qsizepolicy.html#setVerticalStretch)
as appropriate:

    
    
    policy = widg.sizePolicy()
    policy.setVerticalStretch(1)
    widg.setSizePolicy(policy)
    

