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. How to return more than two value in QT?
QtWS25 Last Chance

How to return more than two value in QT?

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 6 Posters 2.3k 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.
  • A Offline
    A Offline
    amarism
    wrote on 18 Jul 2018, 09:57 last edited by
    #1

    I want to return more than two value in QT. For knowing if I want to return two value, I will use QPair<t1,t2>. But now I want to return more than two value?

    J J J 3 Replies Last reply 18 Jul 2018, 09:58
    0
    • A amarism
      18 Jul 2018, 09:57

      I want to return more than two value in QT. For knowing if I want to return two value, I will use QPair<t1,t2>. But now I want to return more than two value?

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 18 Jul 2018, 09:58 last edited by
      #2

      @amarism
      return a struct

      http://www.cplusplus.com/doc/tutorial/structures/


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


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

      1 Reply Last reply
      5
      • A amarism
        18 Jul 2018, 09:57

        I want to return more than two value in QT. For knowing if I want to return two value, I will use QPair<t1,t2>. But now I want to return more than two value?

        J Offline
        J Offline
        JonB
        wrote on 18 Jul 2018, 10:01 last edited by JonB
        #3

        @amarism
        ... or a class (instance), depending on how lightweight/heavyweight is appropriate.
        Or pass in a reference to a struct/class instead of returning one.
        Lots of possibilities.

        J 1 Reply Last reply 18 Jul 2018, 10:03
        3
        • J JonB
          18 Jul 2018, 10:01

          @amarism
          ... or a class (instance), depending on how lightweight/heavyweight is appropriate.
          Or pass in a reference to a struct/class instead of returning one.
          Lots of possibilities.

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 18 Jul 2018, 10:03 last edited by J.Hilk
          #4

          @JonB
          class, struct ..... tomayto, tomahto
          ¯\(ツ)/¯


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


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

          1 Reply Last reply
          4
          • V Offline
            V Offline
            VRonin
            wrote on 18 Jul 2018, 10:41 last edited by
            #5

            std::tuple http://www.cplusplus.com/reference/tuple/tuple/

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            J A 2 Replies Last reply 18 Jul 2018, 10:47
            4
            • V VRonin
              18 Jul 2018, 10:41

              std::tuple http://www.cplusplus.com/reference/tuple/tuple/

              J Offline
              J Offline
              JonB
              wrote on 18 Jul 2018, 10:47 last edited by
              #6

              @VRonin
              Did Python pinch this from C++ or the other way round? :)

              V 1 Reply Last reply 18 Jul 2018, 10:47
              0
              • J JonB
                18 Jul 2018, 10:47

                @VRonin
                Did Python pinch this from C++ or the other way round? :)

                V Offline
                V Offline
                VRonin
                wrote on 18 Jul 2018, 10:47 last edited by
                #7

                @JonB Other way around

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                J 1 Reply Last reply 18 Jul 2018, 10:48
                1
                • V VRonin
                  18 Jul 2018, 10:47

                  @JonB Other way around

                  J Offline
                  J Offline
                  JonB
                  wrote on 18 Jul 2018, 10:48 last edited by
                  #8

                  @VRonin Naughty, naughty C++... :) There are enough headaches in Python already!

                  1 Reply Last reply
                  0
                  • A amarism
                    18 Jul 2018, 09:57

                    I want to return more than two value in QT. For knowing if I want to return two value, I will use QPair<t1,t2>. But now I want to return more than two value?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 18 Jul 2018, 10:54 last edited by
                    #9

                    @amarism said in How to return more than two value in QT?:

                    QPair<t1,t2>. But now I want to return more than two value?

                    QVector<...>, QList<...>, std::array

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    V 1 Reply Last reply 18 Jul 2018, 11:50
                    0
                    • J jsulm
                      18 Jul 2018, 10:54

                      @amarism said in How to return more than two value in QT?:

                      QPair<t1,t2>. But now I want to return more than two value?

                      QVector<...>, QList<...>, std::array

                      V Offline
                      V Offline
                      VRonin
                      wrote on 18 Jul 2018, 11:50 last edited by
                      #10

                      @jsulm said in How to return more than two value in QT?:

                      QVector<...>, QList<...>, std::array

                      Thta only works if all the returned items are of the same type

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      3
                      • Gojir4G Offline
                        Gojir4G Offline
                        Gojir4
                        wrote on 18 Jul 2018, 14:12 last edited by
                        #11

                        @amarism said in How to return more than two value in QT?:

                        But now I want to return more than two value?

                        If the types of values you want to return are supported by QVariant, QVariantList or QVariantMap can be a solution.

                        1 Reply Last reply
                        2
                        • V VRonin
                          18 Jul 2018, 10:41

                          std::tuple http://www.cplusplus.com/reference/tuple/tuple/

                          A Offline
                          A Offline
                          amarism
                          wrote on 19 Jul 2018, 06:51 last edited by
                          #12

                          @VRonin this one work for me thank you

                          1 Reply Last reply
                          1

                          1/12

                          18 Jul 2018, 09:57

                          • Login

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