我通过继承创建了开始菜单QMenu
。我想以QPropertyAnimation
滑动方式显示和隐藏它
问题:
当我明确调用它们时(单击开始按钮),显示和隐藏工作正常。但是当我在开始菜单之外单击时,它会立即隐藏。请建议我这可能是什么原因:
My class is StartMenuUiClass which inherited from QMenu
mptrobj_animation is QPropertyAnimation object
void StartMenuUiClass::show()
{
this->raise();
disconnect(mptrobj_animation,SIGNAL(finished()),this,SLOT(this_hide()));
QMenu::show();
mptrobj_animation->setDuration(500);
mptrobj_animation->setStartValue(*mptrobj_startPosition);
mptrobj_animation->setEndValue(*mptrobj_endPosition);
mptrobj_animation->start();
}
void StartMenuUiClass::hide()
{
mptrobj_animation->setDuration(450);
mptrobj_animation->setStartValue(*mptrobj_endPosition);
mptrobj_animation->setEndValue(*mptrobj_startPosition);
connect(mptrobj_animation,SIGNAL(finished()),this,SLOT(this_hide()));
mptrobj_animation->start();
}
void StartMenuUiClass::this_hide()
{
this->lower();
emit work_Done();
QMenu::hide();
}