#include <QGuiApplication>
#include <QQmlEngine>
#include <QQmlContext>
#include <QQmlComponent>

int main(int argc, char *argv[])
{
  QGuiApplication app(argc, argv);

  QQmlEngine engine;
  QQmlContext *objectContext = new QQmlContext(engine.rootContext());

  QQmlComponent component(&engine, "main.qml");
  QObject *object = component.create(objectContext);

  // ... delete object and objectContext when necessary

  return app.exec();
}

#include <QGuiApplication>
#include <QQuickView>

int main(int argc, char *argv[])
{
  QGuiApplication app(argc, argv);

  QQuickView view;
  view.setSource(QUrl::fromLocalFile("main.qml"));
  view.show();

  return app.exec();
}

Use QQuickView instead of QQmlEngine.
Use QQuickView instead of QQmlEngine.
