I have a QGraphicsScene that I want to copy and append to the start of a list. What is the best method of doing this?
QGraphicsScene* m_scene = new QGraphicsScene(); QGraphicsScene* m_DuplicateScene; QList<QGraphicsScene *>m_list;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Doing this would be very complicated because you don’t know anything about the children of
m_scene. Even if youdynamic_castand create aclone()function for each type ofQGraphicsItem, you still need to remember that other people can subclassQGraphicsItemand create their own type of graphics item, making them unclonable by you.Basically, no, you can’t duplicate a
QGraphicsScene(cloning all items in the process). You can’t even make references to the children of the original scene’s children because aQGraphicsItemcan only have one scene.Unless I’m missing a method call, of course. Searches for ‘clone,’ ‘copy,’ and ‘duplicate’ produced no results, though.
On your second question, use
QList<T *>::push_front. Thus,m_list.push_front(m_DuplicateScene);(Side note: you prepend to the start of a list, and append to the end of a list.)