Is there a way in Qt to create smth like an auto updater?

  • What I want is, when I launch the app it will check for update on git repository and if the new version is present it will make a pull for it. Is there a way I can achieve that?

  • @mandruk1331
    Yes, I believe so.

    If you use qt's InstallerFramework and create an online installer.

    Than during or before start of your app use QNetworkRequest to check for the latest Version online:

    QNetworkRequest request(QUrl("http://www...../Updates.xml"));

    parse the file for the version number

                int begin = sLine.indexOf("<Version>") + QString("<Version>").length();
                int n = sLine.indexOf("</Version>") - begin;
                versionNumber = sLine.mid(begin, n);

    if thats not equal to the current version installed -> do an update.
    Either use QProcess to start the MaintaneceTool or do the update yourself manually. Up to you.

  • @J.Hilk Looks legit, I'll give it a try. But how I can make an update? this is only to check for an update

  • @mandruk1331
    in the Updates.xml file you also have the <DownloadableArchives> entry with the name of all packed archives.

    Download those and unpack/overwrite the files in your installation folder.

  • @J.Hilk No no, I mean how I can make a pull request from qt?

  • @mandruk1331 What do you mean by "pull request"?

  • @ambershark For example: I have an application(old version), a new version is present on my git repository, how I can make my application to check if my git repository has a new version, and if it has one it will download it on Desktop.

  • @mandruk1331 Oh I see, so you want an updater for your application.

    That can be a complex topic. There is no Qt way. You would need to develop your own or use a 3rd party solution.

    You can use Qt components to make your own (that's what I did).

    You can check a webpage (or git) for a newer version. For me that was an xml file I would download, check version differences, etc. If it was new then I would download a package file with the new stuff in it, decompress it, then update my update program (separate exe from my app), launch my update program to update my application. That's pretty much it.

    There's also 3rd party application and libs that can help/do this for you. I'll let you google that though since I wrote my own.

  • Lifetime Qt Champion


    So something like Sparkle ?

  • First of all as others mentioned you should check for the new version by investigating a reply such this : 0.5.19
    This reply is a request to some kind of permanent update url that contained update info(version + download link) and could be edited also (for example
    1.Simply check the version of first part with the version you are running from (in windows it could be query from registry)
    2.Download the new version data to a temporary directory
    3.Unzip the data (so the newer .exe is in your temp dir + some other required data)
    4.Start a new process (updater.exe that is located beside your application .exe) which will close your app -> replace new .exe with older one -> Update registry info -> delete temp dir -> launch your app back

  • @SGaist yes smth like that

  • Lifetime Qt Champion

    The Qt Installer Framework might also be an option.

  • If you want to restart your application after update there is an article in the wiki about that:

    Edit: Well, after a closer look I think it is not enough to just re-instantiate the QApplication if the executable is replaced.
    One approach would be to write the application as a generic plugin loader and load all your application components as libraries. Then you can reload specific components after update of the physical DLL file.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.