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 splash screen a gif video
Forum Updated to NodeBB v4.3 + New Features

How to splash screen a gif video

Scheduled Pinned Locked Moved Solved General and Desktop
53 Posts 3 Posters 15.5k 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.
  • mrjjM mrjj

    @ManiRon
    you do that on label ?

    anyway, you should set both alignments so movie is in center
    alt text

    ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #36

    @mrjj

    This is my code

    processLabel->setGeometry(
    QStyle::alignedRect(
    Qt::LeftToRight,
    Qt::AlignCenter,
    processLabel->size(),
    qApp->desktop()->availableGeometry()

    mrjjM 1 Reply Last reply
    0
    • ManiRonM ManiRon

      @mrjj

      This is my code

      processLabel->setGeometry(
      QStyle::alignedRect(
      Qt::LeftToRight,
      Qt::AlignCenter,
      processLabel->size(),
      qApp->desktop()->availableGeometry()

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #37

      @ManiRon
      ok.
      well u need to center the movie also or
      set size of label to size of movie.

      ManiRonM 1 Reply Last reply
      0
      • mrjjM mrjj

        @ManiRon
        ok.
        well u need to center the movie also or
        set size of label to size of movie.

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by
        #38

        @mrjj

        i have to do both sir .

        mrjjM 1 Reply Last reply
        0
        • ManiRonM ManiRon

          @mrjj

          i have to do both sir .

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #39

          @ManiRon
          well to be on safe size u can do that.
          use resize to size label to width, height of movie

          ManiRonM 2 Replies Last reply
          0
          • mrjjM mrjj

            @ManiRon
            well to be on safe size u can do that.
            use resize to size label to width, height of movie

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on last edited by
            #40

            @mrjj not getting your point

            mrjjM 1 Reply Last reply
            0
            • mrjjM mrjj

              @ManiRon
              well to be on safe size u can do that.
              use resize to size label to width, height of movie

              ManiRonM Offline
              ManiRonM Offline
              ManiRon
              wrote on last edited by
              #41

              @mrjj

              QMovie *movie = new QMovie("C:/Users/data/Documents/untitled14/200w.gif");
              QLabel *processLabel = new QLabel(NULL);
              processLabel->setMovie(movie);
              movie->start();
              processLabel->setWindowFlags(Qt::FramelessWindowHint);
              processLabel->setGeometry(
              QStyle::alignedRect(
              Qt::RightToLeft,
              Qt::AlignCenter,
              processLabel->size(),
              qApp->desktop()->availableGeometry()
              ));
              processLabel->show();

              This Is my current code

              1 Reply Last reply
              0
              • ManiRonM ManiRon

                @mrjj not getting your point

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #42

                @ManiRon
                you can use
                processLabel->resize( some width, some height )
                and i told u how to center movie in label already

                ManiRonM 1 Reply Last reply
                0
                • mrjjM mrjj

                  @ManiRon
                  you can use
                  processLabel->resize( some width, some height )
                  and i told u how to center movie in label already

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by ManiRon
                  #43

                  @mrjj

                  Is this the one to center the movie

                  processLabel->setAlignment(Qt::AlignCenter);

                  for example,
                  I added this in my code,

                  processLabel->resize(100,100);
                  error: invalid use of void expression
                  )
                  ^

                  It showed this error

                  mrjjM 1 Reply Last reply
                  0
                  • ManiRonM ManiRon

                    @mrjj

                    Is this the one to center the movie

                    processLabel->setAlignment(Qt::AlignCenter);

                    for example,
                    I added this in my code,

                    processLabel->resize(100,100);
                    error: invalid use of void expression
                    )
                    ^

                    It showed this error

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #44

                    @ManiRon
                    yes.
                    its AlignCenter = AlignVCenter | AlignHCenter

                    ManiRonM 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @ManiRon
                      yes.
                      its AlignCenter = AlignVCenter | AlignHCenter

                      ManiRonM Offline
                      ManiRonM Offline
                      ManiRon
                      wrote on last edited by
                      #45

                      @mrjj after giving this also the gif is not aligining

                      mrjjM 1 Reply Last reply
                      0
                      • ManiRonM ManiRon

                        @mrjj after giving this also the gif is not aligining

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #46

                        @ManiRon
                        ok. not sure what goes wrong then.

                        ManiRonM 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @ManiRon
                          ok. not sure what goes wrong then.

                          ManiRonM Offline
                          ManiRonM Offline
                          ManiRon
                          wrote on last edited by
                          #47

                          @mrjj oh

                          mrjjM 1 Reply Last reply
                          0
                          • ManiRonM ManiRon

                            @mrjj oh

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #48

                            @ManiRon
                            but if u just resize label, is movie not in the center then ?

                            ManiRonM 1 Reply Last reply
                            0
                            • mrjjM mrjj

                              @ManiRon
                              but if u just resize label, is movie not in the center then ?

                              ManiRonM Offline
                              ManiRonM Offline
                              ManiRon
                              wrote on last edited by
                              #49

                              @mrjj said in How to splash screen a gif video:

                              resize

                              tried to resize but it throwed error

                              processLabel->resize(100,100);
                              error: invalid use of void expression
                              )
                              ^

                              It showed this error

                              mrjjM 1 Reply Last reply
                              0
                              • ManiRonM ManiRon

                                @mrjj said in How to splash screen a gif video:

                                resize

                                tried to resize but it throwed error

                                processLabel->resize(100,100);
                                error: invalid use of void expression
                                )
                                ^

                                It showed this error

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #50

                                @ManiRon
                                please show more of the code.
                                it works here so error is due to do it in odd place or something else i cant see.

                                ManiRonM 1 Reply Last reply
                                0
                                • mrjjM mrjj

                                  @ManiRon
                                  please show more of the code.
                                  it works here so error is due to do it in odd place or something else i cant see.

                                  ManiRonM Offline
                                  ManiRonM Offline
                                  ManiRon
                                  wrote on last edited by
                                  #51

                                  @mrjj

                                  #include "mainwindow.h"
                                  #include <QApplication>
                                  #include<QSplashScreen>
                                  #include<QTimer>
                                  #include<QMovie>
                                  #include<QLabel>
                                  #include<QLayout>
                                  #include<QBoxLayout>
                                  #include <QStyle>
                                  #include <QDesktopWidget>

                                  int main(int argc, char *argv[])
                                  {
                                  QApplication a(argc, argv);
                                  MainWindow w;
                                  QMovie *movie = new QMovie("C:/Users/data/Documents/untitled14/200w.gif");
                                  QLabel *processLabel = new QLabel(NULL);
                                  processLabel->setMovie(movie);
                                  movie->start();
                                  processLabel->setWindowFlags(Qt::FramelessWindowHint);
                                  processLabel->setAlignment(Qt::AlignCenter);
                                  processLabel->setGeometry(
                                  QStyle::alignedRect(
                                  Qt::LeftToRight,
                                  Qt::AlignCenter,
                                  processLabel->size(),
                                  qApp->desktop()->availableGeometry()
                                  )
                                  );
                                  processLabel->show();

                                  QTimer::singleShot(2500,processLabel,SLOT(close()));
                                  QTimer::singleShot(2500,&w,SLOT(show()));
                                  //w.show();
                                  return a.exec();
                                  

                                  }

                                  My full main.cpp code

                                  1 Reply Last reply
                                  0
                                  • mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #52

                                    Hi
                                    Your code works just fine ?

                                    int main(int argc, char *argv[])
                                    {
                                    QApplication a(argc, argv);
                                    MainWindow w;
                                    
                                    QMovie *movie = new QMovie(":/kTTdW2l.gif");
                                    QLabel *processLabel = new QLabel(nullptr);
                                    
                                    processLabel->resize(200,200);  // to make sure its large enough
                                    
                                    processLabel->setMovie(movie);
                                    processLabel->setWindowFlags(Qt::FramelessWindowHint);
                                    processLabel->setAlignment(Qt::AlignCenter);
                                    processLabel->setGeometry(  QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,processLabel->size(),qApp->desktop()->availableGeometry())         );
                                    
                                    movie->start();
                                    processLabel->show();
                                    
                                    QTimer::singleShot(2500,processLabel,SLOT(close()));
                                    QTimer::singleShot(2500,&w,SLOT(show()));
                                    
                                    return a.exec();
                                    }
                                    
                                    ManiRonM 1 Reply Last reply
                                    2
                                    • mrjjM mrjj

                                      Hi
                                      Your code works just fine ?

                                      int main(int argc, char *argv[])
                                      {
                                      QApplication a(argc, argv);
                                      MainWindow w;
                                      
                                      QMovie *movie = new QMovie(":/kTTdW2l.gif");
                                      QLabel *processLabel = new QLabel(nullptr);
                                      
                                      processLabel->resize(200,200);  // to make sure its large enough
                                      
                                      processLabel->setMovie(movie);
                                      processLabel->setWindowFlags(Qt::FramelessWindowHint);
                                      processLabel->setAlignment(Qt::AlignCenter);
                                      processLabel->setGeometry(  QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,processLabel->size(),qApp->desktop()->availableGeometry())         );
                                      
                                      movie->start();
                                      processLabel->show();
                                      
                                      QTimer::singleShot(2500,processLabel,SLOT(close()));
                                      QTimer::singleShot(2500,&w,SLOT(show()));
                                      
                                      return a.exec();
                                      }
                                      
                                      ManiRonM Offline
                                      ManiRonM Offline
                                      ManiRon
                                      wrote on last edited by ManiRon
                                      #53

                                      @mrjj

                                      yes sir, Now working fine

                                      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