0

重複の可能性:
Qt - QPropertyAnimation にバグがありますか?

アニメーションを使用してレイアウト内のウィジェットのサイズを変更するために QWidget maximumWidth をアニメーション化したかったのですが、うまくいきません。私は次のことをしようとしました:

QPropertyAnimation *animation1 = new QPropertyAnimation(m_textEditor2, "maximumWidth");
animation1->setStartValue(0);
animation1->setEndValue(100);
animation1->start();

編集: minimumWidth プロパティの場合、アニメーションは機能しますが、 maximumWidth の場合 - いいえ。したがって、私は彼らのバグレポート サイトでバグを開いた: here

4

1 に答える 1

0

問題は、maximumWidthがウィジェットの実際のサイズに直接変換されないため、アニメーションに使用するのにあまり適したプロパティではないということです。あなたはよりgeometry良い効果を与えるより良い使用法です。たとえば、このように、:をアニメートしQTextEditます。

class QtTest : public QMainWindow
{
    Q_OBJECT
    public:
        QtTest()
        {
            m_textEdit = new QTextEdit(this);
        };

    protected:
        QTextEdit *m_textEdit;

        virtual void showEvent ( QShowEvent * event )
        {
            QWidget::showEvent(event);

            QPropertyAnimation *animation = new QPropertyAnimation(m_textEdit, "geometry");
            animation->setDuration(10000);
            animation->setStartValue(QRect(0, 0, 100, 30));
            animation->setEndValue(QRect(0, 0, 500, 30));

            animation->start();
        }
};
于 2010-07-20T21:03:53.850 に答える