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. Inserting value in the list of QPair

Inserting value in the list of QPair

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 821 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.
  • KiraK Offline
    KiraK Offline
    Kira
    wrote on last edited by
    #1

    Hello All,
    Currently i am using a QList of QPair as below:
    QList<QPair<char,int>> sample;
    I have appended 15 values(for eg.) in the list and now i want to insert or change only the second
    element of the QPair at a given index.
    Current syntax: sample.insert(6,{'J',65});
    What would be the way to change the element at the second position.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Take a lookt at QList::operator[]

      btw: why do you use a list instead a vector here?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      KiraK 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Take a lookt at QList::operator[]

        btw: why do you use a list instead a vector here?

        KiraK Offline
        KiraK Offline
        Kira
        wrote on last edited by
        #3

        @Christian-Ehrlicher : Is using vector more sutaible for my current requirement ?
        Please suggest :)

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Since I don't know what you're doing please read https://doc.qt.io/qt-5/containers.html

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          KiraK 1 Reply Last reply
          3
          • Christian EhrlicherC Christian Ehrlicher

            Since I don't know what you're doing please read https://doc.qt.io/qt-5/containers.html

            KiraK Offline
            KiraK Offline
            Kira
            wrote on last edited by
            #5

            @Christian-Ehrlicher : Ok thanks.

            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