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. adding another parameter to my networkreply function, makes it fail?
Forum Updated to NodeBB v4.3 + New Features

adding another parameter to my networkreply function, makes it fail?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 983 Views 2 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.
  • M Offline
    M Offline
    Monktobia
    wrote on last edited by
    #1

    I am working with parsing JSON that I grab with a GET request through QNetworkManager and QNetworkReply. I handle the finished reply with a slot which triggers the function requestReceived(QNetworkReply *reply) that then goes through the code and does some json parsing etc.

    The problem that I am having is that I want to make the requestReceived function able to take a string parameter in with it so I can perform different operations with the same code.

    When I alter the function to requestReceived(QNetworkReply *reply, QString strFlag) the function no longer responds, even though I haven't added any additional code other than changing the function declarations.

    Does anyone have any idea why this is?

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

      hi and welcome
      As far as I know to successfully connect a signal to a slot (or to another signal),
      they must have the same parameter types in the same order:
      So unless you can change "finished" signal to also have this new parameter ,
      im don't think it will accept it.

      You can check the return value of connect to see if it returns false.

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

        Hi and welcome to devnet,

        When using signals and slots, both must either have matching signatures or the slot have less parameter than the signal but not the opposite.

        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
        2
        • M Offline
          M Offline
          Monktobia
          wrote on last edited by
          #4

          Hmmm so I guess that would mean that since the finished signal is void QNetworkAccessManager::finished(QNetworkReply * reply) that means I would not be able to add an additional string parameter to the signal to match the slot....

          Might have to figure out another way to customize this, just wouldn't want to write a function for each GET request I will make.

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

            What kind of parameter do you have in mind ?

            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

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved