我有一个模态 QDialog,单击按钮会从其下方滑出一个无模态的子 QDialog。我遇到的问题是孩子在动画期间保持在其父母之上。
我想我可以在与父母重叠的孩子部分上应用面具,但感觉就像我错过了一种更明显的方式,将孩子放在父母之下。
我正在使用 Qt 4.5。这是一些示例代码:
void MainWindow::on_myMenu_triggered()
{
parentDlg = new QDialog(this);
parentDlg->setFixedSize(250, 250);
parentDlg->setModal(true);
parentDlg->show();
childDlg = new QDialog(parentDlg);
childDlg->setFixedSize(150, 150);
childDlg->show();
QTimeLine* timeLine = new QTimeLine(1000, this);
connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(childDlgStepChanged(qreal)));
timeLine->start();
}
void MainWindow::childDlgStepChanged(qreal)
{
int parentX = parentDlg->frameGeometry().x();
int parentY = parentDlg->geometry().y();
// Move the child dialog to the left of its parent.
childDlg->move(parentX - 150 * step, parentY);
}
提前致谢。