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. QPropertyAnimation menubar
QtWS25 Last Chance

QPropertyAnimation menubar

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 538 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.
  • Y Offline
    Y Offline
    Yacinoben
    wrote on last edited by Yacinoben
    #1

    Hello,
    I have a QMainWindow class, i want to show/hide the menubar with an slow animation, because she's shown and hidden immediately. There is a QPropertyAnimation class, but i dont how to use this with a menubar
    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #2

      Hi @Yacinoben

      I think that you need to use the QPropertyAnimation with QGraphicsOpacityEffect:

      Here is a simple animation example with QPushButton:

      #include "mainwindow.h"
      
      #include <QApplication>
      #include <QGraphicsOpacityEffect>
      #include <QPropertyAnimation>
      #include <QPushButton>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          MainWindow w;
          QGraphicsOpacityEffect *opacity = new QGraphicsOpacityEffect;
          QPropertyAnimation *anim = new QPropertyAnimation( opacity, "opacity" );
      
          QPushButton *animatedButton = new QPushButton( "Animation", &w );
          animatedButton->setGraphicsEffect( opacity );
      
          anim->setDuration( 2000 );
          anim->setStartValue( 0.1 );
          anim->setEndValue( 1.0 );
          anim->setEasingCurve( QEasingCurve::InCubic );
          anim->start();
      
          w.show();
      
          return a.exec();
      }
      

      You can get inspired from this example to achieve your animation.

      To go further i advise you to read the Qt Animation overview

      1 Reply Last reply
      4

      • Login

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