[Interest] crash when using multiple setSectionResizeMode() calls in QTableView

Frank Rueter | OHUfx frank at ohufx.com
Wed Aug 15 02:34:37 CEST 2018


Hi,

I isolated the problem into a small snippet:
https://gitlab.com/snippets/1744780

This still crashes for me.

I do get the result I’m after by only setting one resize mode, i.e.:

|header.setSectionResizeMode(5, QtWidgets.QHeaderView.Fixed) |

However, what I’m really after is the behaviour of

|header.setStretchLastSection(True) |

but I need the second last section to stretch while the last one remains 
a fixes size.
Is there a way to do this or do I have to write my own header view for that?

Cheers,
frank

On 14/08/18 12:17 PM, Frank Rueter | OHUfx wrote:

> Thanks for testing Marian, much appreciated!
> Interesting it won't crash for you. I will try it in a different IDE 
> (using WingIDE normally) and a different machine in case there is 
> something wrong with my install.
>
> Cheers,
> frank
>
> On 13/08/18 10:10 PM, Marian Beermann wrote:
>> I tried your setSectionResizeMode snippet on a table model
>> whose headerData() is the same as yours and it doesn't cause a crash for
>> me. I don't think the other roles are required (at least to not have a
>> crash).
>>
>> On 13.08.2018 11:30, Frank Rueter | OHUfx wrote:
>>> Thanks. My header data simply looks like this:
>>>
>>> |def headerData(self, section, orientation, role): if orientation ==
>>> QtCore.Qt.Horizontal: if role == QtCore.Qt.DisplayRole: return
>>> self.header_labels[section] |
>>>
>>> where: self.header_labels just contains a list of strings.
>>>
>>> I guess I need to implement size hint roles?! I will try that tomorrow.
>>>
>>> Tanks for the tip!
>>>
>>> Cheers,
>>> frank
>>>
>>>
>>>> Must be something in your code; I'd start by double-checking 
>>>> everything
>>>> related to the header data in your model.
>>>>
>>>> -Marian
>>>>
>>>> On 13.08.2018 05:17, Frank Rueter | OHUfx wrote:
>>>>> Hi all,
>>>>>
>>>>> using PySide2 I am trying to set different resize modes for each 
>>>>> of my
>>>>> columns in a table view, but as soon as I set more than one I get 
>>>>> a crash.
>>>>>
>>>>> Here is what I do:
>>>>>
>>>>> |class MyView(QtWidgets.QTableView): def __init__(self, parent=None):
>>>>> super(MyView, self).__init__(parent) header = self.horizontalHeader()
>>>>> header.setSectionResizeMode(0, QtWidgets.QHeaderView.Fixed)
>>>>> header.setSectionResizeMode(1, QtWidgets.QHeaderView.Interactive) |
>>>>>
>>>>> Is this a bug or am I doing something wrong?
>>>>>
>>>>> Cheers,
>>>>> frank
>>>>>
>>>>>>>>>>
>>>>> -- 
>>>>>
>>>>> ohufxLogo 50x50 <http://www.ohufx.com>
>>>>>     *vfx compositing <http://ohufx.com/compositing.html> | *workflow
>>>>> customisation and consulting <http://ohufx.com/customising.html>* *
>>>>> *<http://ohufx.com/compositing.html>*
>>>>> <http://www.nukepedia.com/nubridge>
>>>>>
>>>>>
>>>>> Your gateway to over 1,000 free tools... right inside of Nuke
>>>>> <http://www.nukepedia.com/nubridge>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Interest mailing list
>>>>> Interest at qt-project.org
>>>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>>>
>>>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180815/55086319/attachment.html>


More information about the Interest mailing list