void MozQWidget::setModal(bool modal) { #if QT_VERSION >= 0x040600 setPanelModality(modal ? QGraphicsItem::SceneModal : QGraphicsItem::NonModal); #else LOG(("Modal QGraphicsWidgets not supported in Qt < 4.6\n")); #endif }
void Window::appear() { //模态化该窗口 //用户必须通过单击该按钮来关闭窗口,在关闭窗口之前, //不能操作当前scene下的其他items if (m_isModal) { setFlags(flags() | ItemIsPanel); QGraphicsScene *const currentScene = scene(); if (currentScene) { if (!s_panelStack.empty()) { QGraphicsItem* item = s_panelStack.top(); item->setPanelModality(NonModal); } setPanelModality(SceneModal); s_panelStack.push(this); currentScene->setActivePanel(this); } } QPropertyAnimation *scale_x = new QPropertyAnimation(scaleTransform, "xScale", this); QPropertyAnimation *scale_y = new QPropertyAnimation(scaleTransform, "yScale", this); QPropertyAnimation *opacity = new QPropertyAnimation(this, "opacity", this); QParallelAnimationGroup *group = new QParallelAnimationGroup(this); scale_x->setEndValue(1); scale_y->setEndValue(1); opacity->setEndValue(1.0); group->addAnimation(scale_x); group->addAnimation(scale_y); group->addAnimation(opacity); group->start(QAbstractAnimation::DeleteWhenStopped); }