I try to register ColorsSource *pSource object to use it in QML but I get erreor in string:
"QQmlContext *context = myObject->rootContext();"
undefined reference to __imp__ZNK12QQuickWidget11rootContextEv
main.cpp
#include "ColorsSource.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQuickWidgets/QQuickWidget>
#include <QQmlContext>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
ColorsSource *pSource = new ColorsSource;
QQuickWidget *myObject = static_cast<QQuickWidget*>(engine.rootObjects().first());
QQmlContext *context = myObject->rootContext();
context->setContextProperty("ColorSource", pSource);
return app.exec();
}