Create Spin Progress bar in Qt

后端 未结 3 1251
误落风尘
误落风尘 2021-01-19 10:57

Create Spin Progress bar in Qt, I want to show progress bar like the one which appears while loading. Please Find Image <script

3条回答
  •  萌比男神i
    2021-01-19 11:30

    Have a look at the Twitter Mobile example application. In the file demos/declarative/twitter/qml/twitter/TwitterCore/Loading.qml there is an implementation in QML of the exact thing you want to achieve:

    import QtQuick 1.0
    
    Image {
        id: loading
        source: "images/loading.png"
        NumberAnimation on rotation {
             from: 0
             to: 360
             running: loading.visible == true
             loops: Animation.Infinite
             duration: 900
         }
    }
    

    Update 1 (reflecting the newly posted code):

    Employing QML just for a spinning load indicator in your otherwise Qt Widgets based application seems overkill to me. I would use a QMovie in conjunction with a QLabel to display an animated GIF image containing the spinner:

    QMovie* spinnerMovie = new QMovie(":/spinner.gif");
    QLabel *spinnerLabel = new QLabel(this);
    spinnerLabel->setMovie(spinnerMovie);
    spinnerMovie->start();
    

    You should also have a look at the documentation for the Qt Resource System to learn how to bundle images with your application and how to load them.

提交回复
热议问题