QHeaderView broke: does not react to setting fonts anymore
I have a somewhat self-caused problem with a QHeaderView: Where before it didn't have any trouble following the font set by the application (qApp), it now never visually changes its font, whatever I try.
It does receive the font change events, it does know about the font it should use (resizing a header section causes elided text to pop up in a ratio that obviously corresponds to the current applications font), its children (e.g. actions) use the proper font, but I never see the visual letters change their appearance. Unless I add a column manually. That one will be perfectly fine.
I hope somebody has any kind of idea, I am completely perplexed by this.
What did you do in between ?
I rearranged the "loading chain" of the application (settings for different elements, data etc.). And maybe some small things left and right - but I didn't make a push before so I can't easily see what I changed.
Also, this whole problem only occurs for horizontal headers. I am trying to track the problem down, but I really don't understand why the labels of the horizontal view are never updated.
Could this happen by setting some kind of invalid font? I found a line of code that certainly has some influence:
That is from the function that loads the settings for the view - if I don't run this line, the view behaves like I would expect. But without a doubt I ran this line before I changed things around, so either this is not the cause, or it has been a bug for a long time. (Which it shouldn't, since it looks pretty innocent.)
Also, this does not "fix" the whole weirdness of the situation. Maybe I should quit coding for today, tomorrow, and the following week and then come back. To be perplexed again. :P
A good night of sleep might help :D
One thing to do is to disable everything related to "styling" and incrementally put it back until it breaks. Also beware of the style sheets if you are using any and also the models you might be using.
I rolled back about ten commits and noticed that the "bug" was already there, but it went unnoticed. Which was frightening as well as reassuring, since my newest changes didn't cause the mess.
I tracked all the trouble down to one (respectively two) things:
When I load the data for my program, I formerly set font and text alignment of the headerview items specifically via
For some reason the first of these prohibits further changes to the font via
which I did not expect.
The latter of these had some weird geometry-issues as a result, but that problem could be solved by using the loaded data in a different way.
So the question now is: Should setting the font on an item specifically disable them to react to changes that are meant for the whole application? This doesn't happen with items within the view (not header items), so I am not sure if I may have stumbled upon a bug or just a very weird implementation detail.