QLinkedList has a copy constructor witch initialize a new list with the shared elements of your original list and copy the list only if you modify the "copy" (copy-on-write)
QLinkedList has a copy constructor witch initialize a new list with the shared elements of your original list and copy the list only if you modify the "copy" (copy-on-write)
zoz (17th September 2010)
Thanks for your quick responce my current bit of code is
Is that correct or incorrect.Qt Code:
ceguSubWidget::ceguSubWidget(QLinkedList<tabptr> tabs) { tablist = tabs; setAttribute(Qt::WA_DeleteOnClose); isUntitled = true; }To copy to clipboard, switch view to plain text mode
Thanks
If you use the list to store pointers to type the copy of the list doesn't copy the objects pointed by the pointers stored in the list (it copy the pointers)
If tabptr is a type defined by you, code a copy constructor witch must do a deep copy (copy of objects the pointers points to)
LE: i think this is your problem: you end up with two pointers (two copy, one in each copy of the list) per each object, if you modify the object by de-reference one pointer, the second pointer will point to the same modified value (not the one before modification)
Last edited by Zlatomir; 18th August 2010 at 10:58.
parsnips146 (18th August 2010), zoz (17th September 2010)
I created a copy constuctor and it working now.
Thanks for your help
Bookmarks