<div dir="ltr"><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">Yes, seems like you're right. If I call setOffset() after calling show() on my window, the offset is visible but disappears as soon as I try to resize the window.</div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">Calling it after resizeEvent or paintEvent doesn't seems to work either, and if it did it would probably be inefficient. I don't really know why does that function even exist if it doesn't seems to have an effect if the view is resizable.</div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">And yes, my intention was to simply add some padding, just a few pixels, on the top of the first row, so that the table view would be slightly separated from the header view, but it seems I will have to give up on that idea.</div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">Thanks for the fast responses! :)</div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
<tr>
<td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
<td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link" target="_blank" style="color:#4453ea">www.avast.com</a>
</td>
</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 20, 2022 at 8:07 PM Maurizio Berti <<a href="mailto:maurizio.berti@gmail.com">maurizio.berti@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Il giorno dom 20 mar 2022 alle ore 17:13 Matej Brezović <<a href="mailto:matey.brezovic@gmail.com" target="_blank">matey.brezovic@gmail.com</a>> ha scritto:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:arial,sans-serif;font-size:small;color:rgb(0,0,0)">Here is the MRE. If you replace view.verticalHeader() with view.horizontalHeader(), the offset will be visible, but doing it with verticalHeader doesn't seem to affect the table view at all.<br></div></div></blockquote><div><br></div>I'm actually surprised that it works for the horizontal header for you, as it doesn't on my computer. And it shouldn't.<br></div><div class="gmail_quote">As written in my previous email, any resize event in the view will always trigger updateGeometries() ( <a href="https://doc.qt.io/qt-5/qabstractitemview.html#updateGeometries" target="_blank">https://doc.qt.io/qt-5/qabstractitemview.html#updateGeometries</a> ), which in the case of QTableView potentially updates (or resets) the offset. Since widgets *always* receive at least one resize event the first time they are shown (especially whenever they are added to layout), your call to setOffset() becomes pointless.</div><div class="gmail_quote"><br></div><div class="gmail_quote">The only way to achieve so on startup would be to call self.show() before setting the offset (but calling self.show() in the init is usually discouraged, while not technically an "error" per se), and/or possibly using a single shot QTimer (a 0 interval should theoretically be enough, but it might be necessary to increase it).</div><div class="gmail_quote"><br></div><div class="gmail_quote">In any case, there are two problems:</div><div class="gmail_quote"><br></div><div class="gmail_quote">- the offset would be reset again as soon as the view will be resized (due any geometry change in any parent widget/layout that could affect it) or the scroll bars are used;</div><div class="gmail_quote">- most importantly, programmatically setting the offset alone is *wrong*, as the view uses the offset to compute the visualRect of items, which is important for the advanced layout and painting required for item views: the result is that, since you're using negative values, the headers will actually translate by the given offset, but most items won't be painted at all, as their geometry will not be considered valid for the "dirty scroll regions" of their indexes; it might be a theoretical bug, but since header offsets are *always* positive, I wouldn't consider it as such.<br><br></div><div class="gmail_quote">It's not clear what you're trying to achieve, but if your intention is to add some "padding" on the top and left of the first row and column, I believe that it would be very difficult to do without breaking the default behavior.<br></div><div><br></div><div><br></div><div>Maurizio<br></div>-- <br><div dir="ltr">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div></div>
</blockquote></div>