Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions QtArduino/QtArduino.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ SOURCES += main.cpp\
HEADERS += mainwindow.h

FORMS += mainwindow.ui
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
12 changes: 10 additions & 2 deletions QtArduino/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
Expand Down Expand Up @@ -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()
Expand Down
34 changes: 31 additions & 3 deletions QtArduino/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
</property>
<property name="font">
<font>
<pointsize>1</pointsize>
<family>Adobe Arabic</family>
<pointsize>16</pointsize>
</font>
</property>
<property name="cursor">
Expand All @@ -66,6 +67,33 @@
</item>
<item>
<widget class="QSlider" name="hsAnalog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>417</width>
<height>40</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>5</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>5</height>
</size>
</property>
<property name="maximum">
<number>255</number>
</property>
Expand All @@ -77,7 +105,7 @@
<item>
<widget class="QProgressBar" name="barAnalog">
<property name="maximum">
<number>255</number>
<number>100</number>
</property>
<property name="value">
<number>0</number>
Expand All @@ -92,7 +120,7 @@
<x>0</x>
<y>0</y>
<width>435</width>
<height>22</height>
<height>23</height>
</rect>
</property>
</widget>
Expand Down
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.