diff --git a/QtArduino/QtArduino.pro b/QtArduino/QtArduino.pro index 24f1d31..90c1184 100644 --- a/QtArduino/QtArduino.pro +++ b/QtArduino/QtArduino.pro @@ -19,3 +19,4 @@ SOURCES += main.cpp\ HEADERS += mainwindow.h FORMS += mainwindow.ui +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/QtArduino/mainwindow.cpp b/QtArduino/mainwindow.cpp index 78291c0..b30ac3b 100644 --- a/QtArduino/mainwindow.cpp +++ b/QtArduino/mainwindow.cpp @@ -1,5 +1,6 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -41,13 +42,20 @@ void MainWindow::onPacketReceived() stream >> digital >> analog; //parse the packet //Change the color of the QLineEdit - if(digital == 1) + if(digital%2 == 1) ui->leDigital->setStyleSheet("QLineEdit { background-color: rgb(136, 195, 240) }"); else ui->leDigital->setStyleSheet("QLineEdit { background-color: none }"); - ui->barAnalog->setValue(analog); //slide the progress bar + ui->leDigital->setText(QString::number(digital)); + if(digital <= 100) + ui->barAnalog->setValue(digital); //slide the progress bar + else + QMessageBox::critical(0 , + "critical message" , "The value received is bigger than 100?", + QMessageBox::Ok | QMessageBox::Default , + QMessageBox::Cancel | QMessageBox::Escape , 0 ); } void MainWindow::sendPacket() diff --git a/QtArduino/mainwindow.ui b/QtArduino/mainwindow.ui index 1793870..bc97686 100644 --- a/QtArduino/mainwindow.ui +++ b/QtArduino/mainwindow.ui @@ -44,7 +44,8 @@ - 1 + Adobe Arabic + 16 @@ -66,6 +67,33 @@ + + true + + + + 0 + 0 + + + + + 417 + 40 + + + + + 0 + 5 + + + + + 0 + 5 + + 255 @@ -77,7 +105,7 @@ - 255 + 100 0 @@ -92,7 +120,7 @@ 0 0 435 - 22 + 23 diff --git a/README b/README new file mode 100644 index 0000000..3c132db --- /dev/null +++ b/README @@ -0,0 +1,9 @@ +QtArduino +========= + +Basic Qt application and Arduino sketch used to teach others how to make them communicate over UDP. +Learn how to use Qt to make an Android UDP app. + +Setup: + (1) Tested work: Use a router as wifi AP, while a Android phone and SocketTool are as wifi station. + (2) Not work: Use Android phone as the wifi AP, and SocketTool cannot send/recv message from the phone. diff --git a/README.md b/README.md deleted file mode 100644 index 3662188..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -QtArduino -========= - -Basic Qt application and Arduino sketch used to teach others how to make them communicate over UDP. \ No newline at end of file