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. SizeHint is not working as I expect it to

SizeHint is not working as I expect it to

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 358 Views
  • 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.
  • A Offline
    A Offline
    Altdelo
    wrote on last edited by
    #1

    So I have a QListWidget fileld with QlistWidgetItems that hold a custom widget I made. That only holdes some lables and an image.

    image at my widget with an image first and then 3 labels

    When I press it I add some more labels at the bottom. This is made by overriding the mousePressEvent in my custom widget (when it get pressed again it removes the extra labels) . And the QListWidget click item singal calls function doing this:

            timeCardWidget = self.cardListWidget.itemWidget(item)
                    
            temp = timeCardWidget.sizeHint()
            item.setSizeHint(temp)
    

    Creating this result:
    same custom widget with changed background and 3 more lables added making it height bigger

    Pressing the item again and it goes back to original size. This works for the most part but sometimes it wont adjust the size at all. Seams very random.

    But I want to add the functionality of when I press one item i want to close the other items.
    So i add this code in the QListWidget clicked singal function:

            for i in range(self.cardListWidget.count()):
                t  = self.cardListWidget.item(i)
                timeWidget = self.cardListWidget.itemWidget(t)
                if t != item:
                    timeWidget.closeItem()
                    t.setSizeHint(timeWidget.sizeHint())
    
            timeCardWidget = self.cardListWidget.itemWidget(item)
                    
            temp = timeCardWidget.sizeHint()
            item.setSizeHint(temp)
    

    Making it call the "close" function from the custom widget. Which dose the same thing when an item is pressed and minimizes by removing the extra labels at the bottom.

    But with this code I get weird behaviour where it will not minimize them all. All without the item that was pressed before the current item is pressed. Showed in the link

    https://gyazo.com/2c090e26b58cdfc32df350588e4233a8

    Im so confused and cant figure out how to fix it. Any help appreciated!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      david2658
      wrote on last edited by
      #2
      This post is deleted!
      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