Important: Please read the Qt Code of Conduct -

How to make version checking success?

  • Hi, I was sharing my application to users from Internet.
    I wonder how many times that people used my app.
    So I make a new url by url-shorter : , and put it in my code.
    When people launch my app, my app will first visit the url to get html then parse the version number in the html content.
    Therefore, I can get the visit number by service.

    But the truth is, it failed.
    I has about 4500 download times, but the visit number only few hundreds.
    I don't know which one is the reason:
    1.My app not even launch success, so version checking also failed.
    2.My version checking code has problem.
    3.Other reasons.

    Here is my checking codes:

    void CheckVersionThread::run(){
        QNetworkAccessManager manager;
        QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("")));
        QEventLoop event_loop;
        QObject::connect(reply , SIGNAL(finished()),
                &event_loop, SLOT(quit()));
        QTimer::singleShot(2000, reply, SLOT(abort()));
        QString htmlString{reply->readAll()};
    //parse  html text content. in htmlString .......................

    Any suggestion for me?
    Thank you for your reading.

  • Moderators

    oh my goodness where to begin.

    • Using threads when not needed (asynchronous api)
    • forcing synchronous behaviour on asynch api
    • overwriting run as threading method
    • not using the exec() of QThread class but using an additional QEventloop
    • calling deleteLater on a stack variable

    the problem is probably your timeout 2 seconds could be to short

Log in to reply