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. Tuple in Qt. How?
Forum Updated to NodeBB v4.3 + New Features

Tuple in Qt. How?

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 7 Posters 15.7k Views 5 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Is there any Qt native solution for using tuple?

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

      Hi,

      What exactly are you looking for ? Tuple is a C++ container, Qt is a C++ framework, you can just use it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        What exactly are you looking for ? Tuple is a C++ container, Qt is a C++ framework, you can just use it.

        B Offline
        B Offline
        bogong
        wrote on last edited by
        #3

        @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

        sierdzioS JKSHJ 2 Replies Last reply
        0
        • B bogong

          @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @bogong said in Tuple in Qt. How?:

          @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

          There is QPair which has some functionality from tuple, but IMO it's better to use a custom struct.

          (Z(:^

          kshegunovK B 2 Replies Last reply
          5
          • sierdzioS sierdzio

            @bogong said in Tuple in Qt. How?:

            @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

            There is QPair which has some functionality from tuple, but IMO it's better to use a custom struct.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @sierdzio said in Tuple in Qt. How?:

            IMO it's better to use a custom struct

            +1000

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2
            • sierdzioS sierdzio

              @bogong said in Tuple in Qt. How?:

              @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

              There is QPair which has some functionality from tuple, but IMO it's better to use a custom struct.

              B Offline
              B Offline
              bogong
              wrote on last edited by
              #6

              @sierdzio There are few things:

              • QPair is only for pair
              • I am seeking something that has kind of functionality for converting tuple to list (for example or something else)
              • Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

              In Erlang huge functionality for it. I though it might be presented in Qt.

              raven-worxR kshegunovK 2 Replies Last reply
              0
              • B bogong

                @sierdzio There are few things:

                • QPair is only for pair
                • I am seeking something that has kind of functionality for converting tuple to list (for example or something else)
                • Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                In Erlang huge functionality for it. I though it might be presented in Qt.

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #7

                @bogong said in Tuple in Qt. How?:

                Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                to be completely type and platform independent you can use QVariantMap (depending how you want to use it in your code you might need to implement conversion methods)

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                B 1 Reply Last reply
                1
                • raven-worxR raven-worx

                  @bogong said in Tuple in Qt. How?:

                  Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                  to be completely type and platform independent you can use QVariantMap (depending how you want to use it in your code you might need to implement conversion methods)

                  B Offline
                  B Offline
                  bogong
                  wrote on last edited by
                  #8

                  @raven-worx Thx ... I know it and published example based on QHash already. But QHash or QMap not tuple itself. The question was especially about tuple itself.

                  1 Reply Last reply
                  0
                  • B bogong

                    @sierdzio There are few things:

                    • QPair is only for pair
                    • I am seeking something that has kind of functionality for converting tuple to list (for example or something else)
                    • Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                    In Erlang huge functionality for it. I though it might be presented in Qt.

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #9

                    @bogong said in Tuple in Qt. How?:

                    Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                    You can't. C++ is statically typed, you can't change the type itself at runtime. The tuple is compiled-in as it appears at compile-time, can't be changed at runtime.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    3
                    • B bogong

                      @SGaist I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

                      JKSHJ Online
                      JKSHJ Online
                      JKSH
                      Moderators
                      wrote on last edited by
                      #10

                      @bogong said in Tuple in Qt. How?:

                      I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

                      What functionality do you want in QTuple? Why don't you want to use std::tuple?

                      I am seeking something that has kind of functionality for converting tuple to list (for example or something else)

                      Write a small function to convert the tuple (or struct) to a vector.

                      • Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                      In Erlang huge functionality for it.

                      Erlang tuples don't allow you to add elements dynamically at runtime either.

                      I though it might be presented in Qt.

                      You can use std::tuple in Qt. It behaves just like the Erlang tuple.

                      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                      B 1 Reply Last reply
                      5
                      • JKSHJ JKSH

                        @bogong said in Tuple in Qt. How?:

                        I am seeking anything that is native for Qt, something like QTuple if it existed. I know about plain C++ Tuple functionality.

                        What functionality do you want in QTuple? Why don't you want to use std::tuple?

                        I am seeking something that has kind of functionality for converting tuple to list (for example or something else)

                        Write a small function to convert the tuple (or struct) to a vector.

                        • Struct - is Ok, but what if I want to get another tuple from origin tuple within added element dynamically in runtime???

                        In Erlang huge functionality for it.

                        Erlang tuples don't allow you to add elements dynamically at runtime either.

                        I though it might be presented in Qt.

                        You can use std::tuple in Qt. It behaves just like the Erlang tuple.

                        B Offline
                        B Offline
                        bogong
                        wrote on last edited by bogong
                        #11

                        @JKSH My apology but you writing about what you do not know:

                        • Erlang tuples don't allow you to add elements dynamically at runtime either. - Really??? How about list_to_tuple function that is part of Erlang core??? How about turning matrix of tuples that been developed by me and published and here official documentation??? Erlang allow to create any tuple you want dynamically through list-conversion, there no need to define any tuple structure before tuple itself. All of it doing dynamically. The tuple in Erlang statical structure itself (like in C++) but it might be created in runtime dynamically without any definitions and I've been experimenting in plain C realisation based on char of elements that looks like tuple in operation. All of it based on Erlang sources.
                        • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - I can't to do even something similar in case of your description and C++ documentation, that is why I've been asking about it (I thought I do not know something in QT only in Qt, I've been asking about ability of Qt manipulate tuples).
                        • Write a small function to convert the tuple (or struct) to a vector. - Why if I need to manipulate tuple itself and it's mentioned in my messages and the question was about it? Or convert something to tuple of random structure?
                        • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - it's totally not. This data-structure manipulation functionality is the key-feature of Erlang, that's why it's so fast and lightweight.

                        It's funny that your wrong reply got upvotes 5 times ...

                        sierdzioS SGaistS 2 Replies Last reply
                        0
                        • B bogong

                          @JKSH My apology but you writing about what you do not know:

                          • Erlang tuples don't allow you to add elements dynamically at runtime either. - Really??? How about list_to_tuple function that is part of Erlang core??? How about turning matrix of tuples that been developed by me and published and here official documentation??? Erlang allow to create any tuple you want dynamically through list-conversion, there no need to define any tuple structure before tuple itself. All of it doing dynamically. The tuple in Erlang statical structure itself (like in C++) but it might be created in runtime dynamically without any definitions and I've been experimenting in plain C realisation based on char of elements that looks like tuple in operation. All of it based on Erlang sources.
                          • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - I can't to do even something similar in case of your description and C++ documentation, that is why I've been asking about it (I thought I do not know something in QT only in Qt, I've been asking about ability of Qt manipulate tuples).
                          • Write a small function to convert the tuple (or struct) to a vector. - Why if I need to manipulate tuple itself and it's mentioned in my messages and the question was about it? Or convert something to tuple of random structure?
                          • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - it's totally not. This data-structure manipulation functionality is the key-feature of Erlang, that's why it's so fast and lightweight.

                          It's funny that your wrong reply got upvotes 5 times ...

                          sierdzioS Offline
                          sierdzioS Offline
                          sierdzio
                          Moderators
                          wrote on last edited by
                          #12

                          @bogong said in Tuple in Qt. How?:

                          It's funny that your wrong reply got upvotes 5 times ...

                          Perhaps the upvotes refer to C++ bits which we can verify. I upvoted because I agree with @JKSH on the C++ part of his answer. I don't know Erlang so I just ignored that part.

                          (Z(:^

                          1 Reply Last reply
                          2
                          • B bogong

                            @JKSH My apology but you writing about what you do not know:

                            • Erlang tuples don't allow you to add elements dynamically at runtime either. - Really??? How about list_to_tuple function that is part of Erlang core??? How about turning matrix of tuples that been developed by me and published and here official documentation??? Erlang allow to create any tuple you want dynamically through list-conversion, there no need to define any tuple structure before tuple itself. All of it doing dynamically. The tuple in Erlang statical structure itself (like in C++) but it might be created in runtime dynamically without any definitions and I've been experimenting in plain C realisation based on char of elements that looks like tuple in operation. All of it based on Erlang sources.
                            • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - I can't to do even something similar in case of your description and C++ documentation, that is why I've been asking about it (I thought I do not know something in QT only in Qt, I've been asking about ability of Qt manipulate tuples).
                            • Write a small function to convert the tuple (or struct) to a vector. - Why if I need to manipulate tuple itself and it's mentioned in my messages and the question was about it? Or convert something to tuple of random structure?
                            • You can use std::tuple in Qt. It behaves just like the Erlang tuple. - it's totally not. This data-structure manipulation functionality is the key-feature of Erlang, that's why it's so fast and lightweight.

                            It's funny that your wrong reply got upvotes 5 times ...

                            SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by VRonin
                            #13

                            @bogong said in Tuple in Qt. How?:

                            @JKSH Erlang tuples don't allow you to add elements dynamically at runtime either. - Really??? How about list_to_tuple??? How about turning matrix of tuples that been developed by me and published

                            From the documentation of Erlang Tuple (emphasis added by me):

                            A tuple is a compound data type with a fixed number of terms.

                            As for list_to_tuple:

                            This method is to convert a list to a tuple

                            This doesn't allow you to add new items to a tuple, it allows you to create a tuple from a list.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            B 1 Reply Last reply
                            2
                            • VRoninV Offline
                              VRoninV Offline
                              VRonin
                              wrote on last edited by
                              #14

                              Can std::tie be something like what you want (example: http://cpp.sh/4ifyc)?

                              You can't, however, convert a generic vector to a tuple at runtime as tuple needs to know its size at compile time.

                              "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

                              B 1 Reply Last reply
                              3
                              • VRoninV VRonin

                                Can std::tie be something like what you want (example: http://cpp.sh/4ifyc)?

                                You can't, however, convert a generic vector to a tuple at runtime as tuple needs to know its size at compile time.

                                B Offline
                                B Offline
                                bogong
                                wrote on last edited by bogong
                                #15

                                @VRonin The question was about QT but NOT std ... But it's partly similar functionality. Similar - because there are no any functionality to create random tuple in runtime. I've been seeking something that is allowing me to use tuple like base-type for messages between Qt application modules. I am trying to define data-type standard for message exchange in my Qt Applications and testing different data type and see what is better to use in my own case.

                                VRoninV 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  @bogong said in Tuple in Qt. How?:

                                  @JKSH Erlang tuples don't allow you to add elements dynamically at runtime either. - Really??? How about list_to_tuple??? How about turning matrix of tuples that been developed by me and published

                                  From the documentation of Erlang Tuple (emphasis added by me):

                                  A tuple is a compound data type with a fixed number of terms.

                                  As for list_to_tuple:

                                  This method is to convert a list to a tuple

                                  This doesn't allow you to add new items to a tuple, it allows you to create a tuple from a list.

                                  B Offline
                                  B Offline
                                  bogong
                                  wrote on last edited by bogong
                                  #16

                                  @SGaist Could you be pleased to get real experience in Erlang before copy-pasting docs that is not in context ... And AGAIN - the question was about QT but not Erlang, not std ...

                                  1 Reply Last reply
                                  0
                                  • B Offline
                                    B Offline
                                    bogong
                                    wrote on last edited by bogong
                                    #17

                                    Issue closed ... Only @sierdzio, @raven-worx and @kshegunov written something that is related to topic. Appreciate it. Thx.

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

                                      Indeed, I should have also mentioned erlang::append_element which returns a new longer tuple based on the term you wanted to add to the original tuple.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      B 1 Reply Last reply
                                      1
                                      • B bogong

                                        @VRonin The question was about QT but NOT std ... But it's partly similar functionality. Similar - because there are no any functionality to create random tuple in runtime. I've been seeking something that is allowing me to use tuple like base-type for messages between Qt application modules. I am trying to define data-type standard for message exchange in my Qt Applications and testing different data type and see what is better to use in my own case.

                                        VRoninV Offline
                                        VRoninV Offline
                                        VRonin
                                        wrote on last edited by VRonin
                                        #19

                                        @bogong Apologies, I used std::tuple in my example but I was referring more of a tuple as an abstract concept more than anything else.

                                        Given your use needs, why wouldn't QVariantList be suitable?

                                        "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

                                        B 1 Reply Last reply
                                        1
                                        • VRoninV VRonin

                                          @bogong Apologies, I used std::tuple in my example but I was referring more of a tuple as an abstract concept more than anything else.

                                          Given your use needs, why wouldn't QVariantList be suitable?

                                          B Offline
                                          B Offline
                                          bogong
                                          wrote on last edited by bogong
                                          #20

                                          @VRonin Because it's super SLOW!!! I've tested it already. In case of huge data exchanging "anti-idiot" guard that is implemented in QVarianList is slowing down this structure itself. The second point - it's dynamical structure itself. Any dynamical always much slower than any statical, that is why I've been seeking something that will allow me to create statical structure dynamically in runtime and use it in any part of application. If data not changed through whole life-circle why would I store it in dynamical manner?

                                          BTW - for me, after huge experience of mixing Objective-C in Qt/QML. The data exchange model that is using in Qt - THE BOTTLENECK in any performance issue of Qt. Sometimes I need to convert 3-5 times one piece of data only for being able to use it in QML. But this is price for cross-platform and I understand it.

                                          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