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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    I want to design bookmark function of QWebView by read and write file like this:
    title1,website1
    title2,website2
    ...
    Can QList use as 2 demension?

    https://github.com/sonichy

    mrjjM 1 Reply Last reply
    0
    • sonichyS sonichy

      I want to design bookmark function of QWebView by read and write file like this:
      title1,website1
      title2,website2
      ...
      Can QList use as 2 demension?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sonichy

      Hi
      I dont understand "2 demension" or what you really ask :)

      sonichyS 1 Reply Last reply
      0
      • mrjjM mrjj

        @sonichy

        Hi
        I dont understand "2 demension" or what you really ask :)

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

        @mrjj
        bookmark( title, url)

        https://github.com/sonichy

        mrjjM 1 Reply Last reply
        0
        • sonichyS sonichy

          @mrjj
          bookmark( title, url)

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sonichy

          Hi, i dont understand what you ask. can you use more words?

          1 Reply Last reply
          0
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Something like this?

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

            Qt has to stay free or it will die.

            sonichyS jsulmJ 2 Replies Last reply
            3
            • aha_1980A aha_1980

              Something like this?

              struct Bookmark {
                QString title;
                QString url;
              }
              
              void test()
              {
                QList<Bookmark> bookmarks;
                bookmarks.title = "Hello";
                bookmarks.url = "World";
              }
              
              sonichyS Offline
              sonichyS Offline
              sonichy
              wrote on last edited by
              #6

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

              struct

              Yes, this is it!
              Can it use method of QList such as append, remove?

              https://github.com/sonichy

              jsulmJ 1 Reply Last reply
              0
              • sonichyS sonichy

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

                struct

                Yes, this is it!
                Can it use method of QList such as append, remove?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @sonichy A QList is a QList, so yes you can use QList methods...

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

                1 Reply Last reply
                1
                • aha_1980A aha_1980

                  Something like this?

                  struct Bookmark {
                    QString title;
                    QString url;
                  }
                  
                  void test()
                  {
                    QList<Bookmark> bookmarks;
                    bookmarks.title = "Hello";
                    bookmarks.url = "World";
                  }
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @aha_1980 A correction:

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

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

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

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

                    @aha_1980 A correction:

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

                    I suppose you may also need to create some operatos for your struct, like == and perhaps >. For full functionality, that is.

                    1 Reply Last reply
                    0
                    • aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      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.

                      Qt has to stay free or it will die.

                      sonichyS 1 Reply Last reply
                      1
                      • VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by
                        #11

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

                        "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

                        Taz742T 1 Reply Last reply
                        3
                        • 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

                                          • Login

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