Skip to main content
3 of 3
Text edit.
TomazicM
  • 27k
  • 24
  • 31
  • 42

QGIS - How to render QgsMapCanvas on QApplication's main window

I am working with C++, QT 5.11.3, Visual Studio 2015 and QGIS 3.7

I'm trying to develop QT c++ application that uses the qgis api. I want to display simple raster and vector map in my qt application. I create QgsVectorLayer and QgsRasterLayer that added to the QgsProject instance and then QgsMapCanvas object. That is no problem so far.

But when i turn the visible property of QgsMapCanvas object, the application crash. The error message and the crash window is above.

QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread ... Reciever (of type 'QGSMapCanvas') ...

enter image description here

I try to this process at different qt thread or main thread no matter what, does not help.
What can i do wrong?