Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Passing multiple parameters into function. How?

    General and Desktop
    3
    6
    707
    Loading More Posts
    • 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.
    • B
      bogong last edited by

      Hello all?

      What is best way in Qt to pass into function multiple parameters? For example I have an issue to create object that might be required in one case 3 properties and in another case 30 properties. In Java Script this case looks like passing into function named array where key-value pairs. I need something like it for CPP.

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @bogong last edited by

        @bogong
        you can use in c++ a list/vector of key value pairs as well.
        But I think you're better off using a class/struct as parameter.

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        B 1 Reply Last reply Reply Quote 2
        • B
          bogong @J.Hilk last edited by

          @J.Hilk Thanks a lot. I've been already using list/vector. Is there any example of class/struct?

          J.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @bogong last edited by

            @bogong
            take a look in this thread,

            it should get you going ;-)
            https://stackoverflow.com/questions/15181765/passing-structs-to-functions

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            B 1 Reply Last reply Reply Quote 2
            • B
              bogong @J.Hilk last edited by bogong

              @J.Hilk I-I-I-H-A-A-A! That's what I've been seeking for! :-))))) I forget the key word - struct. I've been seeking: array, vectors and others but not "struct". Thanks ... Bad morning ... Need coffee ...

              JonB 1 Reply Last reply Reply Quote 0
              • JonB
                JonB @bogong last edited by

                @bogong
                struct is a keyword in C/C++. array/vector are not keywords (std::array/std::vector are standard library class templates). :)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post