This method is poorly named (it does more than just checking the widget's visibility), it unnecessarily accesses the main window (its grandparent widget) API, and is needlesly complicated.
Fix these issues by:
- letting the parent widget decide on whether the child should initially be visible
- not checking for the main_window's visibility
- adding a visibility_changed signal so the visibility of the label widget can automatically be connected to the visibility of the invoice list
Checking the main window's visibility is unnecessary, because (from the QWidget doc):
Calling setVisible(true) or show() sets the widget to visible status if all its parent widgets up to the window are visible. If an ancestor is not visible, the widget won't become visible until all its ancestors are shown.