diff -r ac70c7af6a9b -r b13e7ed9eea3 src/relpipe-out-chart.cpp --- a/src/relpipe-out-chart.cpp Sun Sep 30 18:34:34 2018 +0200 +++ b/src/relpipe-out-chart.cpp Sun Sep 30 20:54:35 2018 +0200 @@ -15,6 +15,11 @@ using namespace relpipe::cli; using namespace relpipe::reader; +// signal/slot parameters must be declared here and registered with qRegisterMetaType() + +Q_DECLARE_METATYPE(string_t) +Q_DECLARE_METATYPE(std::vector) + class RelationalReaderThread : public QThread { private: std::shared_ptr reader; @@ -48,13 +53,23 @@ RelpipeChartMainWindow window; window.show(); - QtRelationalReaderStringHadler handler(&app, &window); + RelationalReaderThread t(reader); + + // Proxy that passes calls from the background thread to the GUI thread using signal-slot mechanism: + QtRelationalReaderStringHadler handler(&t); // &t instead of handler.moveToThread(&t); // QObject::moveToThread: Cannot move objects with a parent + + // see Q_DECLARE_METATYPE above + qRegisterMetaType(); + qRegisterMetaType> (); + + QObject::connect(&handler, &QtRelationalReaderStringHadler::startRelationReceived, &window, &RelpipeChartMainWindow::startRelation, Qt::ConnectionType::QueuedConnection); + QObject::connect(&handler, &QtRelationalReaderStringHadler::attributeReceived, &window, &RelpipeChartMainWindow::attribute, Qt::ConnectionType::QueuedConnection); + QObject::connect(&handler, &QtRelationalReaderStringHadler::endOfPipeReceived, &window, &RelpipeChartMainWindow::endOfPipe, Qt::ConnectionType::QueuedConnection); + reader->addHandler(&handler); // Start background thread - RelationalReaderThread t(reader); t.start(); - // --- int qtResultCode = app.exec();