Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to launch the QMainWindow with a fade in animation?
QtWS25 Last Chance

How to launch the QMainWindow with a fade in animation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 194 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roberrt
    wrote on last edited by
    #1

    I tried launching my window this way:

    #include "stdafx.h"
    #include "mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
        ui.setupUi(this);
    
        setWindowOpacity(0);
    
        QGraphicsOpacityEffect* eff = new QGraphicsOpacityEffect(this);
    
        QPropertyAnimation* ani = new QPropertyAnimation(eff, "windowOpacity");
        ani->setDuration(3000);
        ani->setStartValue(0);
        ani->setEndValue(1);
        ani->setEasingCurve(QEasingCurve::OutBack);
        ani->start(QPropertyAnimation::DeleteWhenStopped);
    }
    
    

    #include "mainwindow.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        MainWindow w;
        w.show();
        return a.exec();
    }
    

    But the window never became visible, I would like to it be initialized with a fade in effect.

    What's the proper way to achieve it?

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @Roberrt said in How to launch the QMainWindow with a fade in animation?:

      QPropertyAnimation

      Can you try?
      ani->setTargetObject( this );
      before start call.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved