/
vasandi
/
DroneControl
Обзор
Документация
Войти
/
vasandi
/
DroneControl
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
DroneSimClient/Application/application.cpp
61 строка
2 KB
Андрей Васильченко
управление дроном в Airsim
08 июл 2026, 13:29
08 июл 2026, 13:29
d1a17d2
Код
Авторство
О чём код?
#include <QStyleFactory> #include <QDebug> #include <QSharedPointer> #include <QThread> #ifndef __linux__ #include <windows.h> #endif #include "application.h" #include "MainWindow/mainwindow.h" #include "Controller/controller.h" #include "ImageServer/imageserver.h" Application::Application(int &argc, char **argv) : QApplication(argc, argv) { #ifndef __linux__ setlocale(LC_ALL, ".UTF-8"); SetConsoleOutputCP(CP_UTF8); #endif setStyle(QStyleFactory::create("Fusion")); } Application::~Application() { } int Application::run() { // VAS: здесь QSharedPointer только для RAII QSharedPointer<Controller> controller = QSharedPointer<Controller>(new Controller()); if (!controller->setInit()) { return -1; } QSharedPointer<MainWindow> mainWindow = QSharedPointer<MainWindow>(new MainWindow()); mainWindow->setController(controller.data()); mainWindow->show(); QThread *thread = new QThread(); Q_CHECK_PTR(thread); connect(controller.data(), SIGNAL(destroyed()), thread, SLOT(quit()), Qt::QueuedConnection); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()), Qt::QueuedConnection); controller->moveToThread(thread); thread->start(); QSharedPointer<ImageServer> imageServer = QSharedPointer<ImageServer>(new ImageServer()); thread = new QThread(); Q_CHECK_PTR(thread); connect(controller.data(), &Controller::signalSaveImage, imageServer.data(), &ImageServer::slotSave, Qt::QueuedConnection); connect(imageServer.data(), &ImageServer::signalAiDataResponse, controller.data(), &Controller::slotAiDataResponse, Qt::QueuedConnection); connect(imageServer.data(), SIGNAL(destroyed()), thread, SLOT(quit()), Qt::QueuedConnection); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()), Qt::QueuedConnection); imageServer->moveToThread(thread); thread->start(); return exec(); }