当对话框打开、从最小化状态最大化或从屏幕外移动时,我想执行某些操作。QT是否有这样的信号?我也不确定在哪里可以找到QT定义的信号列表。
每个QT小部件都有一个“show”信号吗?
如果您查看Qt源代码,您会发现QWidget :: show是一个槽:
public Q_SLOTS:
// Widget management functions
virtual void setVisible(bool visible);
void setHidden(bool hidden);
void show();
show()
、showMaximized()
或showMinimized
插槽。
但我可以猜想您想要进行重载。
virtual void showEvent(QShowEvent *);
virtual void hideEvent(QHideEvent *);
喜欢:
void MyWidget::showEvent(QShowEvent *e)
{
if (isMaximized())
{
if (e->spontaneous())
{
// the author would like to know
// if the event is issued by the system
}
; // the action for maximized
}
else
{
; // the action for normal show
}
}
void MyWidget::hideEvent(QHideEvent *)
{
if (isMinimized())
{
; // the action for minimized
}
else
{
; // the action for hide
}
}
为了识别系统操作小部件的情况,我们可以使用QEvent::spontaneous()。
请参考显示和隐藏事件文档页面: http://doc.qt.io/qt-5/qshowevent-members.html http://doc.qt.io/qt-5/qhideevent.html