I'm tring to copy and paste a custom object from QListView to an other window of the same application, but this class return just a std::ostream, and I don't have access to modify this class.
How can I put this std::ostream in QDatastream then QClipboard for copy and paste process?
void ProjectModel::copymodel(QModelIndex idx){
const mo::model model(modelList.at(idx.row()));
std::ostream *stream;
stream << &model;
QByteArray itemData;
QDataStream datastream(&itemData, QIODevice::WriteOnly);
QMimeData *mimeData = new QMimeData;
mimeData->setData("test", itemData);
QApplication::clipboard()->setMimeData(mimeData);}
the custom class mo::model returns std::stream like that:
namespace mo {
::std::ostream& operator<< (::std::ostream& o, const model& i){
o << ::std::endl << "name: " << i.name ();
if (i.box ())
{
o << ::std::endl << "box: " << *i.box ();
}
for (model::basic_element_const_iterator
b (i.basic_element ().begin ()), e (i.basic_element ().end ());
b != e; ++b)
{
o << ::std::endl << "basic_element: " << *b;
}
for (model::net_const_iterator
b (i.net ().begin ()), e (i.net ().end ());
b != e; ++b)
{
o << ::std::endl << "net: " << *b;
}
for (model::com_position_const_iterator
b (i.com_position ().begin ()), e (i.com_position ().end ());
b != e; ++b)
{
o << ::std::endl << "com_position: " << *b;
}
if (i.com_truthtable ())
{
o << ::std::endl << "com_truthtable: " << *i.com_truthtable ();
}
if (i.com_pos_titles ())
{
o << ::std::endl << "com_pos_titles: " << *i.com_pos_titles ();
}
return o;}}