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. QListWidget setItemWidget spacing on right
Forum Updated to NodeBB v4.3 + New Features

QListWidget setItemWidget spacing on right

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpythonpyside
4 Posts 2 Posters 793 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.
  • E Offline
    E Offline
    emreeeeeeeeeeeee
    wrote on last edited by emreeeeeeeeeeeee
    #1

    Hello,
    I have QListWidget. I am using setItemWidget to show my custom widget on QListWidget.

    This is my list:
    qlistwidget.png

    Code for add widget to list:

    wid = MyCustomWidget(data=data)
    item = QListWidgetItem()
    item.setData(Qt.UserRole+1, data) # for access data
    item.setSizeHint(wid.sizeHint())
    Liste.addItem(item) # my QListWidget
    Liste.setItemWidget(item, wid)
    

    But as you can see in image, there is gap/spacing on right side. I want this gap/spacing to be on the left. So the gap/spacing on left and right side should be equal.
    Note: I will have like 200 item/widget. I would appreciate if you could suggest other objects for performance.
    Thanks.

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

      Hi and welcome to devnet,

      For performance, QStyledItemDelegate is what you should use.

      setItemWidget is to show some static content but not to show static content on every cells.

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

      E 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        For performance, QStyledItemDelegate is what you should use.

        setItemWidget is to show some static content but not to show static content on every cells.

        E Offline
        E Offline
        emreeeeeeeeeeeee
        wrote on last edited by emreeeeeeeeeeeee
        #3

        @SGaist Thank you.
        This is my animated custom widget: Imgur my custom widget
        I have never used QStyledItemDelegate. Is it possible to do the same as in this gif (animations too) with QStyledItemDelegate?

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

          AFAIK, it should be doable.

          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