Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problems with QNetwork | QNetworkAccessManager



  • how do i setProperty/getProperty on my reply object to store the board name associated with the request?

            self.xBoard = ""
            self.nam = QtNetwork.QNetworkAccessManager()
            self.nam.connect(self.handleResponse)
    
        def doRequest(self):
            print("Run")
            print("#----------------------------------#")
            for key, value in self.board.items():
                url = "http://" + value["ip"]
                self.xBoard = value["Name"]
    
                print("doRequests : " + self.xBoard)
                print("http://" + value["ip"])
    
                req = QtNetwork.QNetworkRequest(QUrl(url))
                self.nam.get(req)
    
        def handleResponse(self, reply):
            er = reply.error()
    
            if er == QtNetwork.QNetworkReply.NoError:
                bytes_string = reply.readAll()
    
                print("")
                print("#----------------------------------#")
                print("Result")
                print("#----------------------------------#")
                print(str(bytes_string, 'utf-8'))
                print("handleResponse : " + self.xBoard)
    
                self.board[self.xBoard]['Status'] = "Online"
            else:
                print("Error occured: ", er)
                print(reply.errorString())
    
                self.board[self.xBoard]['Status'] = "Offline"
    

  • Lifetime Qt Champion

    Why do you keep deleting threads where you already have answers to create new ones ?

    This subject was already talked about here.



  • @SGaist it's still alive?


  • Lifetime Qt Champion

    No, you deleted it but I still had a tab opened on it.



  • @SGaist i could still see the thread! anyway, why is QNetworkReply only reply once?

    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    #----------------------------------#
    Result
    #----------------------------------#
    handleResponse : hello world!
    Små Sure : Online
    #----------------------------------#
    Result
    #----------------------------------#
    handleResponse : hello world!
    Studio Lights : Online
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    Run
    #----------------------------------#
    doRequests : http://192.168.10.138
    doRequests : http://192.168.10.146
    doRequests : http://192.168.10.184
    doRequests : http://192.168.10.2
    

    is there anything i need todo? :S


  • Lifetime Qt Champion

    @Kris-Revi said in Problems with QNetwork | QNetworkAccessManager:

    @SGaist i could still see the thread!

    Because you are the owner. Since you have undone the deletion, I strongly suggest we stay in that thread over there rather than continuing here because it just fragments the information.

    Closing this one.


Log in to reply