Why menu doesn't show up from QAction added to QToolBar in PyQt6?

The following code shows up the QMenu on clicking the QToolButton in pyqt5. But not in Pyqt6. Is this an behavioral change in Qt6 ? I could not find anything in the documentation.

import sys

from qtpy.QtWidgets import (QApplication, QAction, QMenu, QWidget,
                            QVBoxLayout, QToolBar)


class Widget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        layout = QVBoxLayout(self)
        toolbar = QToolBar(parent=self)

        menu = QMenu()
        menu.addAction('one')
        menu.addAction('two')
        menu.addAction('three')

        action = QAction( "Number", self)
        action.setMenu(menu)
        toolbar.addAction(action)

        layout.addWidget(toolbar)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    icons.init()
    wid = Widget()
    wid.show()
    sys.exit(app.exec())

This is no longer an issue when the QMenu gets a correct parent.

QMenu doesn't show up from QAction addded to QToolBar in Qt6. | Qt Forum.