Unsolved lambda expression capture
-
Hi,
is there a way to do this??
connect(this, &MainWindow::loadFile, [viewer](QString value) {viewer->m_dataEngine->loadFile(value); });
I'm in the MainWindow class and want to connect the loadFile signal from MainWindow with the loadFile function from GeometryEngine that is member of viewer.
I thought i could make a lambda expression in viewer, but viewer does not hold an instance of MainWindow. So i hoped that there is a way to make it from MainWindow.
-
Hi,
The clean way here would be to add a slot to your viewer class that will call whatever needed. The internals of that viewer class is of no concern to MainWindow.
-
@QT-static-prgm Did you try it?
If viewer is a member variable of MainWindow you can do it like this:connect(this, &MainWindow::loadFile, [this](QString value) {viewer->m_dataEngine->loadFile(value); });
But as @SGaist said it would be better to implement a slot in Viewer.
MainWindow should not care/know about Viewer internals like m_dataEngine.