Skip to content

iterate only over visible children in menu

Alexander Stippich requested to merge work/astippich/menuVisibleChildren into master

!136 (merged) caused a small regression for a menu containing checkable and non-checkable items that I observed while hacking on Skanpage:

menu Upon opening the hamburger menu (not hovering the items!), the menu items without checkboxes are not properly aligned. They will align correctly once one of the items is hovered.

This is due to iterating over each menu item while they are still invisible because the menu is initially invisible. Hence the checkable status of the item will not be recognized. It seems that the onChildrenChanged signal is not emitted when the visibility of the children changes (I don't know if that is a Qt bug by itself). Luckily, we have the list of visibleChildren that we can use, which should also be a little bit more efficient overall.

I found that the on(Visible)Children signal is constantly emitted just while hovering the item, so the loop will get evaluated quite often. Don't know how that can be improved, though.

Haven't found any regressions (yet 😄)

Merge request reports