This is a project from university, I have to make a “paint” and now I am stuck at making copying and pasting. shape
is an abstract class from which other real shapes like Rectangle
and Circle
are inherited.
std::shared_ptr<shape> m_selectedShape = nullptr;
std::shared_ptr<shape> m_copiedShape = nullptr;
...
else if ((event->key() == Qt::Key_C) && (event->modifiers() == Qt::ControlModifier)){
if(m_selectedShape != nullptr){
m_copiedShape = m_selectedShape;
}
update();
}
else if ((event->key() == Qt::Key_V) && (event->modifiers() == Qt::ControlModifier)){
if(m_copiedShape != nullptr){
//How?
}
update();
}
...
I tried using make_shared
but as the shared_ptr are shape
, which is an abstract class, I can not.
1