[osg-users] QPropertyAnimation with openscengraph window

Maxim Senin ok23senya at yahoo.com
Tue Aug 22 02:09:58 PDT 2017


Hi, i have QWidget and i want him to disappear duration X time. In qt my code works:

... 

Thank you!

Cheers,
Maxim
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QPropertyAnimation>
#include <QGraphicsEffect>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect();
    ui->pushButton->setGraphicsEffect(eff);
    QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity");
    a->setDuration(3500);
    a->setStartValue(0);
    a->setEndValue(1);
    a->setEasingCurve(QEasingCurve::InCubic);
    a->start(QPropertyAnimation::DeleteWhenStopped);
    //connect(a,SIGNAL(finished()),this,SLOT(hideThisWidget()));

    connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(hideButton()) );

}

MainWindow::~MainWindow()
{
    delete ui;

}

void MainWindow::hideButton()
{
    QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect();
    ui->pushButton->setGraphicsEffect(eff);
    QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity");
    a->setDuration(3500);
    a->setStartValue(1);
    a->setEndValue(0);
    a->setEasingCurve(QEasingCurve::OutBack);
    a->start(QPropertyAnimation::DeleteWhenStopped);
}


but then i use this code with OSG, he doesn't work.

The window where everything happens is osgViewer::CompositeViewer.
How can I solve this problem?

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71491#71491







More information about the osg-users mailing list