Project

General

Profile

Actions

Improvements #11868

open

Define a signal for when the content of `WStackedWidget` changes

Added by Matthias Van Ceulebroeck 9 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
08/09/2023
Due date:
% Done:

0%

Estimated time:

Description

A WStackedWidget can be used to define a stack of widgets. A widget can then be selected as the "active" one (using setCurrentIndex() or setCurrentWidget()).
The item/index that is then selected will be explicitly called, ensuring that the developer is fully aware of the content changing.

However, a WMenu uses a WStackedWidget to display its content. One can listen to the itemSelected() signal to retrieve that item that was selected. However, it is possible that in a structure with nested menus, the current selected menu item doesn't change, but the displayed widget in the stack does change. For example, if there is a tree of menus of depth 2.

  • Item 1 (Menu)
    • SubItem 1 (*)
    • SubItem 2
  • Item 2 (Menu)
    • SubItem 3 (*)
    • SubItem 4

Say we have visited SubItem 1, and SubItem 3 already. Currently we are looking at SubItem 1. If we switch to SubItem 3 again, the contents of the stack change. However, the itemSelected() of the main menu is called, but not that of the submenu (Item 2 itself).

This may require custom logic from developers to find the current selected item. As such, a signal can be added to WStackedWidget (something like currentWidgetChanged()) to ensure that this change can be noticed.

No data to display

Actions

Also available in: Atom PDF