Sorry for my extremely sloppy writing. I'll try again:

Hi,

If you set wordWrap to True for a QLabel which has been added to a widget with a layout, the resizing of the parent widget is kinda strange: The widget can be resized to nothing etc.

I've attached a small example, displaying two widgets which both include a QLabel: one with wordwrap on, and one without. Try to resize the two widgets and see if you can reproduce the behavior.

This must be a bug, right?

Best regards,

Mads

import sys
from PyQt4 import QtCore, QtGui

class Label(QtGui.QLabel):
    """
       Class for defining a word wrapped label.
    """
    def __init__(self, parent=None):
        """
           Constructor.
        """
        # Call base class constructor
        QtGui.QLabel.__init__(self, parent)

        # Add some text
        text = """Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."""
        self.setText(text)

class Widget(QtGui.QWidget):
    def __init__(self, word_wrap=False, parent=None):
        """
           Constructor.
        """
        # Call base class constructor
        QtGui.QWidget.__init__(self, parent)

        # Add some text
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)

        # Add some widgets
        label = Label()
        label.setWordWrap(word_wrap)
        layout.addWidget(label)

        push_button = QtGui.QPushButton('Press me')
        layout.addWidget(push_button)

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    widget1 = Widget(word_wrap=False)
    widget1.show()

    widget2 = Widget(word_wrap=True)
    widget2.show()

    sys.exit(app.exec_())
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to