As a Scala/Java girl sometimes I am totally losing my mind in C++ / QT.
I have very simple thread class like :
mongoUpdate::mongoUpdate(QObject *parent) :
QObject(parent)
{
mongocxx::options::client client_options;
mongocxx::instance inst{};
mongocxx::uri uri("mongodb://xxxx");
mongocxx::client client(uri);
// db = client["aces"];
// coll = db["aces"];
qDebug() << "PARENT Mongo Connected" << endl;
// MONGO
}
void mongoUpdate::send_mongo(QImage m_qimg)
{
Write the mongo m_qimg. bla
}
Problem is send_mongo part is not aware I have a connection.
How can I make a mongo connection to be know and usable by send_mongo thread ?
Edit 1
I create a singleton mongo instance as described in : instance_management.cpp
Now it is connecting and able the insert data. But when coll.insert_one
called main GUI thread freezes even the mongoUpdate running in a different thread with movetothread way in QT.
Even we are using the mongoupdate in a different thread why it's blocking mainGui ?