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. Calculate Traffic through QNetworkAccessManager
Qt 6.11 is out! See what's new in the release blog

Calculate Traffic through QNetworkAccessManager

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 660 Views 1 Watching
  • 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.
  • J Offline
    J Offline
    johnlamericain
    wrote on last edited by
    #1

    Hi everyone,

    I would like to calculate the traffic (bytes received and sent) in my application (using a QWebView and also a download manager for file content).

    I would like the most generic solution (lowest level, that's why I think QNetworkAccessManager is the best way to do it if I configure the network request to always use the same manager).

    I explored the following:

    @
    connect(networkManager(), &QNetworkAccessManager::finished, this, &WebWidget::replyFinished);
    @

    but reply->bytesAvailable() is usually 0 because the bytes was already consume by the QWebView I assumed.

    I try to use QWebPage::totalBytes() but it's only when the page is loaded, watching a video in youtube doesn't update this value when the page is finished loaded.

    @
    QNetworkRequest request(url);
    currentReply = networkManager()->get(request);
    connect(currentReply, &QNetworkReply::readyRead, this, &WebWidget::replyReadyRead);
    @

    it works to get the number of bytes for a request, but doesn't really work in coordination to QWebView, I don't want to use QNerworkAccessManager::get() but of course QWebView::load().

    @
    void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
    @

    I also assumed this function from QNetworkReply would be interresting.

    Thanks for your help/suggestions.

    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