I need to be able to copy a Qwidget so I can duplicate a window because it will change during runtime. is this possible?
void Duplicate(QWidget * Show)
{
//I tried...
Qwidget Shw = *Show; //but operator= is private
//and the copy constructor (I think), which is also private
Qwidget Shw(*Show);
//
Shw.Show();
}
This is by design. The usual way to solve it is to implement a method (typically called
clone()) that allows you to specify the exact semantics that should apply when copying instances of your class. This approach also prevents unintentional copies from being made implicitly, e.g by container classes.From the Qt docs: