QMenu correctly displays a QWidgetAction that contains a QWidget with its own dimensions, but when the menu is torn off (and becomes an independent window) things go wrong. The window is sized to properly display any actions that were added with addAction(str), but the QWidgetAction's QWidget is almost completely hidden.
This code reproduces the problem:
#!/usr/bin/env python
from PySide2 import QtCore, QtWidgets
def main():
app = QtWidgets.QApplication()
window = QtWidgets.QWidget()
layout = QtWidgets.QHBoxLayout()
window.setLayout(layout)
button = QtWidgets.QPushButton("Push Me")
menu = QtWidgets.QMenu()
menu.setTearOffEnabled(True)
menu.addAction("Ok")
qwa = QtWidgets.QWidgetAction(menu)
big_button = QtWidgets.QPushButton("Big Button")
big_button.setMinimumWidth(400)
big_button.setMinimumHeight(400)
qwa.setDefaultWidget(big_button)
menu.addAction(qwa)
button.setMenu(menu)
layout.addWidget(button)
window.show()
app.exec_()
main()


This is caused by the fact that when a QMenu is teared off, you don't actually see the same QMenu object, but a new QMenu based from it.
The QMenu documentation actually explains this, but I admit that more emphasis on this important aspect could have been used:
Then, note this section from the QWidgetAction description:
The above is not only valid for toolbars, but for menus ("an action container that supports QWidgetAction"), including tear off menus: if you add the same QWidgetAction to more than one menu and that action only implements
setDefaultWidget(), the widget will only be visible in the first menu, which is exactly what happens when using tearing off.The solution is then to subclass QWidgetAction and use
createWidget()instead:Note that you should probably connect the buttons'
clickedsignal to the action'striggeredone.