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 create QList of 2 demension?
Forum Updated to NodeBB v4.3 + New Features

How to create QList of 2 demension?

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 9 Posters 6.5k Views 1 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.
  • VRoninV VRonin

    you can also use QList<QPair<QString,QString> > bookmarks

    Taz742T Offline
    Taz742T Offline
    Taz742
    wrote on last edited by
    #12

    @VRonin said in How to create QList of 2 demension?:

    QList<QPair<QString,QString> > bookmarks

    http://www.cplusplus.com/reference/utility/make_pair/

    Do what you want.

    1 Reply Last reply
    0
    • BjornWB Offline
      BjornWB Offline
      BjornW
      wrote on last edited by
      #13

      @VRonin said in How to create QList of 2 demension?:

      you can also use QList<QPair<QString,QString> > bookmarks

      Using QPair is a good idea because it automagically provides operator== etc, which is useful if you want to search and sort ^_^

      Taz742T 1 Reply Last reply
      1
      • BjornWB BjornW

        @VRonin said in How to create QList of 2 demension?:

        you can also use QList<QPair<QString,QString> > bookmarks

        Using QPair is a good idea because it automagically provides operator== etc, which is useful if you want to search and sort ^_^

        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by
        #14

        @BjornW
        Also if you using std::set<std::pair<T, T> > or std::multiset or std::priority_queue<> you dont need seperate sort function.
        He is sorted by the first drawer.

        Do what you want.

        BjornWB 1 Reply Last reply
        -1
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #15

          Wouldn't it be more convenient to use a QList<QList<QString> > or QList<QVector<QString> > ? those have an easier constructor than the QPair<T1, T2> qMakePair(const T1 &value1, const T2 &value2) path?


          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.

          Taz742T 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            Wouldn't it be more convenient to use a QList<QList<QString> > or QList<QVector<QString> > ? those have an easier constructor than the QPair<T1, T2> qMakePair(const T1 &value1, const T2 &value2) path?

            Taz742T Offline
            Taz742T Offline
            Taz742
            wrote on last edited by
            #16

            @J.Hilk
            It's not convenient for me if I need only two divisions.
            i think std::pair<T, T> is best way if you dont forget what does it mean first and second after a while. haha

            Do what you want.

            L.GogsL 1 Reply Last reply
            -1
            • Taz742T Taz742

              @J.Hilk
              It's not convenient for me if I need only two divisions.
              i think std::pair<T, T> is best way if you dont forget what does it mean first and second after a while. haha

              L.GogsL Offline
              L.GogsL Offline
              L.Gogs
              wrote on last edited by
              #17

              @Taz742
              სწორი ხარ.

              Taz742T 1 Reply Last reply
              0
              • L.GogsL L.Gogs

                @Taz742
                სწორი ხარ.

                Taz742T Offline
                Taz742T Offline
                Taz742
                wrote on last edited by Taz742
                #18

                @L.Gogs
                იფ იუ დონთ ნაუ ჰაუ თუ ფლეი შათაფ ანდ ფლეი

                Do what you want.

                L.GogsL 1 Reply Last reply
                -1
                • Taz742T Taz742

                  @L.Gogs
                  იფ იუ დონთ ნაუ ჰაუ თუ ფლეი შათაფ ანდ ფლეი

                  L.GogsL Offline
                  L.GogsL Offline
                  L.Gogs
                  wrote on last edited by
                  #19

                  @Taz742
                  სოლომონ?

                  Taz742T 1 Reply Last reply
                  0
                  • L.GogsL L.Gogs

                    @Taz742
                    სოლომონ?

                    Taz742T Offline
                    Taz742T Offline
                    Taz742
                    wrote on last edited by
                    #20

                    @L.Gogs
                    ბიჩ ბლიადდდ.

                    Do what you want.

                    1 Reply Last reply
                    -1
                    • Taz742T Taz742

                      @BjornW
                      Also if you using std::set<std::pair<T, T> > or std::multiset or std::priority_queue<> you dont need seperate sort function.
                      He is sorted by the first drawer.

                      BjornWB Offline
                      BjornWB Offline
                      BjornW
                      wrote on last edited by
                      #21

                      @Taz742 I was compering to the alternative using a struct. Also set and list are different, he didn't mention anything about unique values.

                      1 Reply Last reply
                      0
                      • aha_1980A aha_1980

                        Sorry, my example was not fully correct:

                        struct Bookmark {
                          QString title;
                          QString url;
                        }
                        
                        void test()
                        {
                          QList<Bookmark> bookmarks;
                          Bookmark mark;
                          mark.title = "Hello";
                          mark.url = "World";
                          bookmarks.append(mark);
                        }
                        

                        So yes, all QList function work here.

                        sonichyS Offline
                        sonichyS Offline
                        sonichy
                        wrote on last edited by sonichy
                        #22

                        @aha_1980
                        Thank you for your resolution, I have finished history record of QWebView with 3 members!
                        https://github.com/sonichy/Qt_HTYBrowser

                        // define
                        struct History {
                            QString stime;
                            QString title;
                            QString surl;
                        };
                        
                        // append
                        QList<History> historys;
                        History history;
                        history.stime = strlist.at(0);
                        history.title = strlist.at(1);
                        history.surl = strlist.at(2);
                        historys.append(history);
                        
                        // use
                        historys.at(i).stime
                        historys.at(i).surl
                        historys.at(i).title

                        https://github.com/sonichy

                        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