2

我有一个模态 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);
}

提前致谢。

4

1 回答 1

0

子小部件总是在父小部件上呈现,因此您必须打破这种关系才能直接实现您正在寻找的效果。然后,如果两个对话框具有相同的父级,则可以使用 raise() 或 lower()。

于 2010-10-08T15:32:52.290 回答