我有一个停靠小部件,现在我想添加一个“窗口”菜单来显示/隐藏小部件。很容易做
showPropWinAct = new QAction(tr("&Properties"), this);
showPropWinAct->setStatusTip(tr("Show properties window"));
showPropWinAct->setCheckable(true);
connect(showPropWinAct, SIGNAL(toggled(bool)), propertiesWindow, SLOT(setVisible(bool)));
问题是当用户单击小部件上的 [x] 时,showPropWinAct
不会切换。如何在不触发第二个 setVisible 信号的情况下侦听此事件并正确切换操作(可能来自关闭事件的信号,以及来自connect
上述事件的信号)?