Forums

OverviewFelgo 2 Support (Qt 5) › How to use AppActivityIndicator while downloading data from Internet

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18133

    Niyazi

    Hi,

    I want to use Felgo AppActivityIndicator when my app downloads some data from Internet.

    When my app starts its get some json data from internet using  Component.onCompleted: { }. After user needs new data he7she can activate  AppActivityIndicator icon to get new data. While is geting new data I need to activate AppActivityIndicator  animation and when download completse I need to stop the AppActivityIndicator  animation

    How do I do that?  I couldn’t find any example for that. Any help please.

    #18143

    Alex
    Felgo Team

    Hi,

    the AppActivityIndicator has the methods startAnimating() and stopAnimating(). Depending on how you get your data, you can start the indicator when requesting your data and stop the indicator when you received your data?

    For an xmlhttprequest this could look something like this:

    function loadJsonData() {
         var xhr = new XMLHttpRequest
         xhr.onreadystatechange = function() {
           if (xhr.readyState === XMLHttpRequest.DONE) {
             var dataString = xhr.responseText
             app.jsonData = JSON.parse(dataString)
             indicator.stopAnimating()
           }
         }
         xhr.open("GET", "your-url")
         xhr.send()
         indicator.startAnimating()
       }

    Cheers,
    Alex

    #18145

    Niyazi

    Thanx Alex, I will update my code.

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support