2
我有一个模式的QDialog,点击一个按钮,从它下面滑出一个无模式的孩子QDialog。我遇到的问题是,在动画过程中,孩子停留在父母的顶部。如何在其父项下隐藏QWidget?
我想我可以在面对父母重叠的孩子身上涂抹面具,但感觉就像我错过了将孩子放在父母下面的更明显的方式。
我正在使用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);
}
在此先感谢。
谢谢,我没有考虑过重新装修。当我尝试将动画子对话框重新设置回到时间线结束时的父对话框时,我遇到了问题,最后创建了新的子对话框并销毁了用于动画的子对话框。 – Robin 2010-10-08 16:33:01