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?

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 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.HilkJ JonBJ jsulmJ 3 Replies Last reply
    0
    • A amarism

      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.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on 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

        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?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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.HilkJ 1 Reply Last reply
        3
        • JonBJ JonB

          @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.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on 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
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on 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

            JonBJ A 2 Replies Last reply
            4
            • VRoninV VRonin

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

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

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

              VRoninV 1 Reply Last reply
              0
              • JonBJ JonB

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

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on 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

                JonBJ 1 Reply Last reply
                1
                • VRoninV VRonin

                  @JonB Other way around

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • A amarism

                    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?

                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on 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

                    VRoninV 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @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

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on 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 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
                        • VRoninV VRonin

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

                          A Offline
                          A Offline
                          amarism
                          wrote on last edited by
                          #12

                          @VRonin this one work for me thank you

                          1 Reply Last reply
                          1

                          • Login

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