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 can I copy the Qmap ?
Forum Updated to NodeBB v4.3 + New Features

How can I copy the Qmap ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmapqt creator
3 Posts 3 Posters 3.3k Views 2 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.
  • E Offline
    E Offline
    Eng.Jason
    wrote on 13 Jun 2016, 07:15 last edited by
    #1

    Hello , I have some question about Qmap.

    I want copy Qmap(A) to another Qmap(B) . so i try like this.

    QMap <int, my_Struct> Amap;
    QMap <int, my_Struct> Bmap;
    
    Amap = Bmap;   ->  it occurred about Segmentation fault at here.
    

    is this wrong way?

    how can i copy the qmap? is that have a another ways?

    please help me.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      micland
      wrote on 13 Jun 2016, 07:32 last edited by micland
      #2

      Your code looks fine. The assignment operator for QMap is overloaded and should support your code snippet (see http://doc.qt.io/qt-5/qmap.html#operator-eq)
      Do you do any fancy stuff in the copy constructor / assignment operator of my_Struct that may lead to the segmentation fault?

      1 Reply Last reply
      1
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 13 Jun 2016, 21:12 last edited by
        #3

        Hi,

        To add to @micland, what's the base class of my_Struct ?

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

        1 Reply Last reply
        0

        3/3

        13 Jun 2016, 21:12

        • Login

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