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. QMainWindow (top level window) is not animating with QPropertyAnimation
Forum Updated to NodeBB v4.3 + New Features

QMainWindow (top level window) is not animating with QPropertyAnimation

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 278 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    shanmugaraja
    wrote on last edited by
    #1

    In my app, I have created the main window by deriving QMainWindowand that window will be displayed after some time later with animation. I am trying to implement the opacity animation for that window using QPropertyAnimation and ```
    QGraphicsOpacityEffect

    
    mainwindow.hpp
    
    

    class MainWindow : public QMainWindow
    {
    QBasicTimer *display_timer;
    void show_overlay_with_delay(void);

    };

    mainwindow.cpp
    
    

    MainWindow::MainWindow(QWidget *parent)
    : ui(new Ui::MainWindow)
    {
    setWindowOpacity(0.0);

    display_timer = new QBasicTimer();
    display_timer->start(5000, this);
    

    }

    void MainWindow::timerEvent(QTimerEvent *event)
    {
    if (this->display_timer->timerId() == event->timerId()) {
    this->show_overlay();
    }
    }

    void MainWindow::show_overlay(void)
    {
        QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
        this->setGraphicsEffect(eff);
        QPropertyAnimation *animation = new QPropertyAnimation(eff,"opacity");
        animation->setDuration(5000);
        animation->setStartValue(0);
        animation->setEndValue(1);
        animation->setEasingCurve(QEasingCurve::InBack);
        animation->start(QPropertyAnimation::DeleteWhenStopped);
    }
    
    
    But the window is not animating and also not displayed. I tried it by changing the attributes as opacity and also windowOpacity attributes. But now luck.
    
    I am trying this Mac platform. But it should be working in Windows platform as per the answer on [Qt Topic.](https://forum.qt.io/topic/60977/animate-window-top-level-widget-opacity/2)
    
    Is there any other way, Can we animate the window (top-level) with opacity animation?
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      QEasingCurve::InBack seems not to work (didnt look into why)
      and im not sure QGraphicsOpacityEffect can work on a top level widget aka
      a window.
      Same code applied to a widget in a form works.
      alt text

      Also does
      setWindowOpacity(xxx); work on macOS. ?
      that is other kind of transparency than QGraphicsOpacityEffect provides.
      (impl. details may vary pr platform.)

      Please note "windowOpacity" versus"opacity" for 2 codes.

      1 Reply Last reply
      0

      • Login

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