Qt World Summit: Register Today!

Delegate's SizeHint not runned before resizing window

  • Hello folks !

    Here is my problem:
    I've got a delegate on my Table View second column.
    The size is controlled by sizeHint function. However, the first sizeHint is only called when the window is manually resized. Otherwise, the sizeHint is not called and the second column is smaller as expected.

    When running application, before resizing window:
    at start

    After resizing window, when sizeHint is called::

    When instanciating my Table View, I correctly set ResizeToContent for second column.

    self.tableView.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
    self.tableView.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeToContents)

    Here is the delegate's sizeHint:

    def sizeHint(self, option, index):
        """Gives an hint about the minimal size of the element to the view"""
        arrow_button_width = 25
        width = 20+ 2 * arrow_button_width
        height = 45
        return QtCore.QSize(width, height)

    Do you have an idea how to "enforce" sizeHint when running the application ?

  • I bump the topic

  • Lifetime Qt Champion


    Please have some patience and allow at least 24 hours before bumping your own thread. This is voluntary driven forum and people answering may not live in the same time zone as you.

    As for your issue, please provide a minimal runnable script.
    You also need to provide the platform you are running your code on as well as bindings version.

Log in to reply