Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Delegate's SizeHint not runned before resizing window
Forum Updated to NodeBB v4.3 + New Features

Delegate's SizeHint not runned before resizing window

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 348 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nbusser
    wrote on last edited by
    #1

    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::
    resized

    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 ?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nbusser
      wrote on last edited by
      #2

      I bump the topic

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved