Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6: Rendering of overlay TreeView is broken #13760

Open
2 tasks done
kadet1090 opened this issue May 1, 2024 · 8 comments · May be fixed by #13807
Open
2 tasks done

Qt6: Rendering of overlay TreeView is broken #13760

kadet1090 opened this issue May 1, 2024 · 8 comments · May be fixed by #13807
Labels
3rd party: Qt 6 Issue related to Qt 6 Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD UI/UX

Comments

@kadet1090
Copy link
Contributor

kadet1090 commented May 1, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

When building against Qt6 (which now is forced for Arch linux users) tree view background is rendered for every column of the tree even for indentations:
image

This is not supposed to happen. This regression is caused by this commit in Qt: qt/qtbase@16e0e7c. Long story short, until Qt 6.5 Qt did not render items for non-alternating backgrounds, leaving that task for delegates. Delegate for rendering tree items relied on this behavior and now it is broken.

edit: It's even worse, there is another commit that is part of this regression: qt/qtbase@483ae6c. This one translates PanelItemViewRows into PanelItemViewItems to "properly" render background because it is non-styleable from qss. I don't know why it is done like that instead of introducing something like ::row into qss.

I don't see any easy way around that issue as it is not guarded by any if statement that could be abused. My only idea is to somehow override behavior of the

            style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this);

to be no-op but I don't know how to achieve that. One way would be to use QProxyStyle to override this but this is not compatible with QSS which renders this solution useless.

Full version info

OS: Arch Linux (awesome)
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.37065 +1 (Git)
Build type: Debug
Branch: more-at-the-end
Hash: 0590b51dabb5380ff983b4df2b7cb2cb21db2d18
Python 3.12.3, Qt 6.7.0, Coin 4.0.2, Vtk 9.3.0, OCC 7.7.2
Locale: English/United States (en_US)
Installed mods: 
  * Assembly3 0.12.0
  * SelectorToolbar
  * ExtremeProDark 2.9.0
  * BIM 2021.12.0
  * CurvedShapes 1.0.4
  * IconThemes
  * sheetmetal 0.3.0
  * OpenTheme 2024.4.20
  * Glass (Disabled)
  * lattice2 1.0.0
  * A2plus 0.4.60n
  * Curves 0.6.13

Subproject(s) affected?

None

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@maxwxyz maxwxyz added Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD UI/UX 3rd party: Qt 6 Issue related to Qt 6 labels May 1, 2024
@maxwxyz
Copy link
Collaborator

maxwxyz commented May 1, 2024

@realthunder could you support here?

@MisterMakerNL
Copy link
Contributor

I don't get this background. Why not remove it?

@kadet1090
Copy link
Contributor Author

I don't get this background. Why not remove it?

Readability, models can have different color, have multiple lines etc so only way to ensure that tree items are easily readable in all scenarios is to provide background for items that will have good contrast against text and hide distracting stuff like lines fighting for attention around text.

@MisterMakerNL
Copy link
Contributor

Thats why Realthunder added the text effect.
If applied gently it's hardly vissible, but it does work.

@kadet1090
Copy link
Contributor Author

It does not work well enough as with busy model it still is not readable enough, at least for me.

@MisterMakerNL
Copy link
Contributor

Could you try the new added overlay stylesheets?
I had no issues, but also don't think much people tried it.

@kadet1090
Copy link
Contributor Author

People have different tolerance for things being readable or not, depending on various factors. Realthunder implemented it (but remember, that he also implemented other options - including one with background) in the same way as movie captions are done - white text with black outline so it should be readable in every scenario. Unfortunately this effect is mostly effective with big text (bigger outline separating text from the rest of the picture), while we deal with small fonts. In our case we can also get a lot of lines with similar thickness in small area making it very busy and so needing more brain power to process it, requiring to focus on that particular area instead of being able to quickly scan it. I don't mind making the background optional - if for somebody background is distracting (which totally could be the case), I do however mind taking away option of having it.

This is not a thread for this discussion anyway, so let's not go off-topic anymore.

@kadet1090
Copy link
Contributor Author

kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 2, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 2, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 3, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 4, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 4, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 5, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 5, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
kadet1090 added a commit to kadet1090/FreeCAD that referenced this issue May 5, 2024
This aims to fix rendering of tree view items in Qt6. While I don't
belive that this is a good way to fix this, I am worried that it is the
only way to do ir.

BC BREAK: This change introduces artificial QTreeView widget that can be
targeted using QSS and can be used in the delegate for painting background of
items. `QTreeView::item` would now be used to render background for the
whole row, while each cell can be targeted using `#DocumentTreeItems`
selector.

More details on implementation:
https://stackoverflow.com/questions/78414383/qt6-disable-drawing-of-default-background-for-qtreeview-items/78421604#78421604

Fixes: FreeCAD#13760
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party: Qt 6 Issue related to Qt 6 Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD UI/UX
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants