Switch to CMake for Qt build
This commit is contained in:
parent
2138179760
commit
761fc4aa90
8 changed files with 73 additions and 53 deletions
|
@ -1,5 +1,7 @@
|
|||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <caml/mlvalues.h>
|
||||
#include <caml/callback.h>
|
||||
|
@ -9,14 +11,38 @@ void load_caml(char *argv[])
|
|||
caml_main(argv);
|
||||
}
|
||||
|
||||
void print_closure(const std::string &closure_name) {
|
||||
value * closure_f = caml_named_value(closure_name.c_str());
|
||||
if (closure_f == nullptr) {
|
||||
std::cerr << "ERROR: Unreachable closure " << closure_name << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
const char *str = String_val(caml_callback(*closure_f, Val_unit));
|
||||
std::cout << closure_name << ": " << str << "\n";
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
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);
|
||||
|
||||
load_caml(argv);
|
||||
|
||||
std::cout << "test std::cout" << "\n";
|
||||
std::cerr << "test std::cerr" << "\n";
|
||||
print_closure("name");
|
||||
print_closure("version");
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue