src/spacenav-demo-qt.cpp
branchv_0
changeset 4 1383ad1c4f57
parent 2 21b0b2b0547e
child 6 49560660d230
equal deleted inserted replaced
3:6baa91ac3199 4:1383ad1c4f57
     1 /**
     1 /**
     2  * Spacenav Demo Qt
     2  * Spacenav Demo Qt
     3  * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
     4  *
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License, or
     7  * the Free Software Foundation, either version 3 of the License, or
     8  * (at your option) any later version.
     8  * (at your option) any later version.
    17  */
    17  */
    18 #include <stdio.h>
    18 #include <stdio.h>
    19 
    19 
    20 #include <QApplication>
    20 #include <QApplication>
    21 #include <QThread>
    21 #include <QThread>
    22 #include <QMainWindow>
       
    23 
       
    24 #include <stdlib.h>
       
    25 #include <signal.h>
       
    26 #include <X11/Xlib.h>
       
    27 #include <spnav.h>
       
    28 
    22 
    29 #include "SpacenavReceiver.h"
    23 #include "SpacenavReceiver.h"
    30 //#include "SpacenavWindow.h"
    24 #include "SpacenavWindow.h"
    31 
    25 
    32 int main(int argc, char**argv) {
    26 int main(int argc, char**argv) {
    33 	setlocale(LC_ALL, "");
    27 	setlocale(LC_ALL, "");
    34 	QApplication app(argc, argv);
    28 	QApplication app(argc, argv);
    35 
    29 
    36 	SpacenavReceiver t;
    30 	SpacenavReceiver t;
       
    31 
       
    32 	SpacenavWindow w;
       
    33 	w.show();
       
    34 
       
    35 	QObject::connect(&t, &SpacenavReceiver::spacenavEvent, &w, &SpacenavWindow::spacenavEvent, Qt::ConnectionType::QueuedConnection);
       
    36 
    37 	t.start();
    37 	t.start();
    38 
       
    39 	// QMainWindow w;
       
    40 	// w.show();
       
    41 
       
    42 	int qtResultCode = app.exec();
    38 	int qtResultCode = app.exec();
    43 
    39 
    44 	if (t.isRunning()) {
    40 	if (t.isRunning()) {
    45 		std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl;
    41 		std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl;
    46 		t.terminate();
    42 		t.terminate();