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. Is there a way in Qt to create smth like an auto updater?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 6 Posters 3.9k 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.
  • mandruk1331M mandruk1331

    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?

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #2

    @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

    if(sLine.contains("<Version>")){
                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.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    mandruk1331M 1 Reply Last reply
    3
    • J.HilkJ J.Hilk

      @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

      if(sLine.contains("<Version>")){
                  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.

      mandruk1331M Offline
      mandruk1331M Offline
      mandruk1331
      wrote on last edited by mandruk1331
      #3

      @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

      J.HilkJ 1 Reply Last reply
      0
      • mandruk1331M mandruk1331

        @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

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #4

        @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.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        mandruk1331M 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @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.

          mandruk1331M Offline
          mandruk1331M Offline
          mandruk1331
          wrote on last edited by
          #5

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

          Mandruk1331

          A 1 Reply Last reply
          0
          • mandruk1331M mandruk1331

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

            A Offline
            A Offline
            ambershark
            wrote on last edited by
            #6

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

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            mandruk1331M 1 Reply Last reply
            0
            • A ambershark

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

              mandruk1331M Offline
              mandruk1331M Offline
              mandruk1331
              wrote on last edited by
              #7

              @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

              A 1 Reply Last reply
              0
              • mandruk1331M mandruk1331

                @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.

                A Offline
                A Offline
                ambershark
                wrote on last edited by
                #8

                @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.

                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Hi,

                  So something like Sparkle ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  mandruk1331M 1 Reply Last reply
                  1
                  • IMAN4KI Offline
                    IMAN4KI Offline
                    IMAN4K
                    wrote on last edited by
                    #10

                    First of all as others mentioned you should check for the new version by investigating a reply such this : 0.5.19 https://yourarchivesite.com/update/current/data
                    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 https://site.com/availableUpdate).
                    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

                    1 Reply Last reply
                    2
                    • SGaistS SGaist

                      Hi,

                      So something like Sparkle ?

                      mandruk1331M Offline
                      mandruk1331M Offline
                      mandruk1331
                      wrote on last edited by
                      #11

                      @SGaist yes smth like that

                      Mandruk1331

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        The Qt Installer Framework might also be an option.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • simowS Offline
                          simowS Offline
                          simow
                          wrote on last edited by simow
                          #13

                          If you want to restart your application after update there is an article in the wiki about that:
                          https://wiki.qt.io/How_to_make_an_Application_restartable

                          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.

                          Let's Try To Negotiate!

                          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