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. QNetworckAccessManager & Connecting
QtWS25 Last Chance

QNetworckAccessManager & Connecting

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    shahriar25
    wrote on last edited by
    #1

    Hi,
    I want to download a list of icons for the items of my QStandardItemModel (appsModel). when I do this it does nothing:

    void MainWindow::downloadIcons()
    {
    for (int i=0; i<appsModel->rowCount(); ++i)
    {
    QUrl iconUrl("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");

        QNetworkRequest request(iconUrl);
    
        QNetworkAccessManager *tempManager = new QNetworkAccessManager;
        tempManager->get(request);
    

    connect(tempManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(setDownloadedIcons(QNetworkReply*)));
    }
    }

    for now the link is the google image but I will set it to the data of items of my model. It's just for testing. what am I doing wrong?

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

      Hi,

      You should also connect the error signal

      By the way, why are you re-creating a new QNetworkAccessManager each time ?

      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
      • S Offline
        S Offline
        shahriar25
        wrote on last edited by
        #3

        Hi, @SGaist
        My code doesn't work. I can't see how the problem is related to connecting the error signal. can you explain?

        And also What do you mean by one QNetworkAccessManager? How can I do that?

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

          That would allow you to know that something wrong happened by at least printing the error on the console.

          I mean don't recreate one each time you send a request. Currently you also have a memory leak since you never delete them.

          Just add one as a member of your MainWindow class and use it to send all the requests.

          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
          • S Offline
            S Offline
            shahriar25
            wrote on last edited by
            #5

            Hi, thank you the problem is solved

            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