eyllanesc / QtExamples

Translations of the official Qt examples into PyQt5 (also PySide2) and more. :bowtie: :octocat:
GNU General Public License v3.0
51 stars 11 forks source link

PyQt5 Multiple Level Header View #2

Closed mire22 closed 3 years ago

mire22 commented 4 years ago

Hi!

I would like to make a multiple level header view for a QTableView. The example that you made in C++ https://github.com/eyllanesc/stackoverflow/tree/master/questions/46469720 is exactly what I want but in Python. So I translated all the code from C++ to Python with PyQt5 library. The results are that the vertical header works well but not the horizontal header: only the first line is displayed. I compared again and again the full code to find the error but I can't fix it.

You will find the full Python code attached and screenshots: MultipleLevelHeaderView_python.zip In GridTableHeaderView > PaintSection, I printed the cells data and the horizontal header cells are well created and painted... But at the end, they don't show.

Thank you for your help! Rémi

Images

Screenshot_github

Screenshot_c++ Minor issues are that I don't see the horizontal lines in the headers and the cyan background doesn't show.

Screenshot_python I don't have the 2 lines in the horizontal header ("cell5" and "cell6" are lacking). Moreover "cell2" and "cell3" are not vertically centered in the vertical header.

Environment:

eyllanesc commented 4 years ago

@mire22 When executing your code in Linux with PyQt5 5.15 I get:

So I will review because some cells are not shown, the style seems strange to me but try putting: app.setStyle("fusion"), in addition to that tell me what you get when you run: print(app.style().metaObject().className())

mire22 commented 4 years ago

With app.setStyle("fusion") the lines and the cyan background appear: Screenshot_python_fusion Command print(app.style().metaObject().className()) returns:

mire22 commented 4 years ago

Hi, I just tried with Qt version 5.9.6 and it is the same. I can't see how to solve this issue. Thank you for your help. Rémi

mire22 commented 3 years ago

I found the bug! Christmas magic! It was one tabulation too many... For who may be interested: MultipleLevelHeaderViewPython.zip