2

ボタンをクリックすると、モードレスの子 QDialog がその下からスライドします。私が抱えている問題は、アニメーション中に子が親の上にとどまることです。

親と重なっている子の部分にマスクを適用することで回避できると思いますが、子を親の下に配置するだけのより明白な方法が欠けているように感じます。

Qt4.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 に答える