Possible bug or change in PyQt5.10.1, width changing when adding item to QTreeWidget

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible bug or change in PyQt5.10.1, width changing when adding item to QTreeWidget

THOMAS EDVARDSEN

Hello,


I encountered an issue with PyQt 5.10.1, where if i have a QTreeWidget with sorting enabled, adding a QTreeWidgetItem causes the width to double. (Or at least increase)

This only happens in PyQt 5.10.1. (Tested 5.9 and 5.10, where this does not happen). If i disable the sorting, it will not increase the width of the widget. I have not been able to install 5.11 because i can't load the site, nor is it on pypi yet, so i don't know if it's fixed in that version. Provided is a minimal example to prove my issue:


##############


from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QApplication
from PyQt5.QtCore import pyqtSignal


class Tree(QTreeWidget):
    sendItem = pyqtSignal(QTreeWidgetItem)

    def __init__(self):
        super().__init__(parent=None)

        self.setSortingEnabled(True)  # Remove or set to False to get pore 5.10.1 behaviour

        item = QTreeWidgetItem(self)
        item.setText(0, 'test test test test test test test test test test test test testtesttesttest')

        self.itemClicked.connect(self.add_item)

    def add_item(self, _, __):
        item = QTreeWidgetItem(self)
        item.setText(0, 'broken')


if __name__ == '__main__':
    app = QApplication([])
    a = Tree()
    a.show()
    app.exec_()


######################


Simply run and click the item with text, and it will add another item to the tree. If sorting is enabled, width will change, if not, it won't. In earlier versions, width is unchanged regardless of sorting. 

Anyone know, can test, or happen to know possible workaround if this is a problem in 5.11 too? 


My OS is windows 10, and python version is 3.6.5 64-bit.



Thomas. 


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug or change in PyQt5.10.1, width changing when adding item to QTreeWidget

Florian Bruhin
On Tue, Jun 26, 2018 at 08:36:30PM +0000, THOMAS EDVARDSEN wrote:
> Simply run and click the item with text, and it will add another item to
> the tree. If sorting is enabled, width will change, if not, it won't. In
> earlier versions, width is unchanged regardless of sorting. 
>
> Anyone know, can test, or happen to know possible workaround if this is a
> problem in 5.11 too? 

Seems fine with Qt 5.11. Probably this Qt bug:
https://bugreports.qt.io/browse/QTBUG-65478

Florian

--
https://www.qutebrowser.org | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug or change in PyQt5.10.1, width changing when adding item to QTreeWidget

FeRD
In reply to this post by THOMAS EDVARDSEN

Florian Bruhin wrote: 
Seems fine with Qt 5.11. Probably this Qt bug:
https://bugreports.qt.io/browse/QTBUG-65478

I'm not so sure about that, compiling and running the example project attached to that bug didn't give me any problems (running under Qt 5.10.1 from Fedora 28 packages), but I definitely saw the issues with Thomas's original script. Also, that bug is about manually-resized column widths being reset on sort order changes, not columns growing wider with every change.

THOMAS EDVARDSEN wrote:
I encountered an issue with PyQt 5.10.1, where if i have a QTreeWidget with sorting enabled, adding a QTreeWidgetItem causes the width to double. (Or at least increase)

This only happens in PyQt 5.10.1. (Tested 5.9 and 5.10, where this does not happen). If i disable the sorting, it will not increase the width of the widget. I have not been able to install 5.11 because i can't load the site, nor is it on pypi yet, so i don't know if it's fixed in that version. 

Huh, interesting. I ran your example code on Fedora with the python-qt5-5.10-3.fc28 package installed, and I definitely saw the bug you mentioned. First click, a horizontal scrollbar appeared, and then every time I clicked an item, the list widget grew wider — even though the width of the column itself was constrained to the window width. Resizing the window resized the list, but there was still that extra area to the right that didn't change size even as the window grew.

In fact, did you notice that every time you reverse the sort order of the column, the width also grows? So it doesn't seem to be merely adding items that widens the widget, it's any interaction or update.

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Possible bug or change in PyQt5.10.1, width changing when adding item to QTreeWidget

FeRD


On Wed, Jun 27, 2018 at 1:18 AM FeRD <[hidden email]> wrote:

Florian Bruhin wrote: 
Seems fine with Qt 5.11. Probably this Qt bug:
https://bugreports.qt.io/browse/QTBUG-65478

I'm not so sure about that, compiling and running the example project attached to that bug didn't give me any problems (running under Qt 5.10.1 from Fedora 28 packages), but I definitely saw the issues with Thomas's original script. Also, that bug is about manually-resized column widths being reset on sort order changes, not columns growing wider with every change.


Aha, THIS bug (which is marked as a duplicate of the one you mention) does sound like exactly what I was seeing with Thomas's test script:

https://bugreports.qt.io/browse/QTBUG-67625

And it's reportedly fixed as well, in Qt 5.11.

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt