Results 1 to 13 of 13

Thread: Copying vector of pointers to another vector

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Copying vector of pointers to another vector

    Hello!

    I'm having a problem in trying to copy the content of a vector to another vector.

    Essentially what I want is to create a vector of pointer
    Qt Code:
    1. Alarm *vector[];
    To copy to clipboard, switch view to plain text mode 
    and add them pointers that point to objects
    Qt Code:
    1. for (...;...;...)
    2. {
    3. vector[] = new Alarm;
    4. etc.
    5. }
    To copy to clipboard, switch view to plain text mode 
    than I want to pass that vector to a different class through a function that will makes a different vector
    Qt Code:
    1. Alarm *alarms[];
    To copy to clipboard, switch view to plain text mode 
    that will "copy" the content of the first, i.e. will point to the same objects of the first one in the same sequence. I though that I should do the following:
    Qt Code:
    1. for (...;...;...)
    2. {
    3. alarms[] = vector[];
    4. etc.
    5. }
    To copy to clipboard, switch view to plain text mode 
    but despite the compiler runs OK, when I try to use the software it crashes, displaying the message that the software stop working and I must close.

    Notice, though, that this only happens when the copy is done in this second class. If the same copy is done in the original class, everything runs fine! So, what is the problem?

    Details:

    I'm calling the following method to do the copy:

    Qt Code:
    1. v_alarmmanagment->readExistingAlarms(v_vector, numberofalarms);
    2.  
    3. /***************/
    4.  
    5. void AlarmManagment::readExistingAlarms(Alarm *alarms[], int numb)
    6. {
    7. vector2[numb] = alarms[numb];
    8. }
    To copy to clipboard, switch view to plain text mode 


    Thanks!


    Momergil

    -----
    Edit: only now I saw that I should have posted this thread in the "General Programming" section. Sorry!
    Last edited by Momergil; 18th September 2011 at 02:34. Reason: found necessary

Similar Threads

  1. Copying Vector Images to the Windows Clipboard
    By pherthyl in forum Qt Programming
    Replies: 4
    Last Post: 22nd May 2008, 17:49
  2. vector of vector and computes
    By mickey in forum General Programming
    Replies: 1
    Last Post: 15th May 2008, 12:47
  3. insert in a vector of vector
    By mickey in forum General Programming
    Replies: 3
    Last Post: 6th March 2007, 08:45
  4. vector of vector size
    By mickey in forum General Programming
    Replies: 5
    Last Post: 13th February 2007, 15:59
  5. <vector> and new
    By mickey in forum General Programming
    Replies: 11
    Last Post: 18th May 2006, 15:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.