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

Frank Rueter | OHUfx frank at ohufx.com
Wed Aug 15 12:55:28 CEST 2018


Ha, you are a star! I will try that first thing in the morning!

Thanks!
frank

On 15/08/18 9:30 PM, Marian Beermann wrote:
> Hi Frank,
>
> I didn't spot it earlier, but now I saw it. You're manipulating
> QHeaderView's sections before setting the model on the view. Most things
> you can do with a QHeaderView require a model to be present.
>
> If you move these calls to after a model has been set, everything works.
>
> https://gist.github.com/enkore/727e3f912c8f9380017fb78591f2a05e
>
> -Marian
>
> On 8/15/18 2:34 AM, Frank Rueter | OHUfx wrote:
>> 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
>>



More information about the Interest mailing list