2023-10-22 22:00:00 +00:00
|
|
|
#include "binding.h"
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2024-08-18 04:42:11 +00:00
|
|
|
extern "C" {
|
2024-10-13 05:31:18 +00:00
|
|
|
extern void miqt_exec_callback(intptr_t cb, int argc, void* argv);
|
2024-08-18 04:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-05 22:22:29 +00:00
|
|
|
PQApplication QApplication_new(int* argc, char** argv) {
|
|
|
|
// QApplication takes these parameters byref, not by value
|
|
|
|
return new QApplication(*argc, argv);
|
2023-10-22 22:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PQWidget QWidget_new() {
|
|
|
|
return new QWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QWidget_show(PQWidget self) {
|
|
|
|
static_cast<QWidget*>(self)->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
PQPushButton QPushButton_new(const char* label, PQWidget parent) {
|
|
|
|
return new QPushButton(label, static_cast<QWidget*>(parent));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QPushButton_show(PQPushButton self) {
|
|
|
|
static_cast<QPushButton*>(self)->show();
|
|
|
|
}
|
|
|
|
|
2024-10-13 05:31:18 +00:00
|
|
|
void QPushButton_connect_pressed(PQPushButton self, intptr_t cb) {
|
2024-08-18 04:42:11 +00:00
|
|
|
QPushButton::connect(static_cast<QPushButton*>(self), &QPushButton::pressed, [=]() {
|
|
|
|
miqt_exec_callback(cb, 0, nullptr);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-22 22:00:00 +00:00
|
|
|
int QApplication_exec(PQApplication self) {
|
|
|
|
return static_cast<QApplication*>(self)->exec();
|
|
|
|
}
|