Category Archives: Qt: The Face Of Embedded

GUI: Plug n Play Duino

The main idea behind the “Plug n Play Duino” model was the ease of implementation of algorithms of line following, edge avoiding and all such sort of works… or “To make it a toy”(in english :P)

As Saurabh gave a detailed list of features of this board here,

http://www.embedded4fun.com/plug-n-play-du…a-new-approach/

We built a GUI for this board, which makes it a child play, when it comes to line following.

 

Line Followe GUI
Line Followe GUI

Well As you can see, the GUI allows you to : Read the rest of this entry

Advertisements

PyQt4: Getting into action

After a short tutorial, let’s make a “Serial Data Reader application”.
PROBLEM STATEMENT: The data has to be read from the serial port and to be displayed to a text box in the form.

SOLUTION: The first step of every solution is to make the Flow-Chart. The flow chart for this problem will be like this.

flowchart

The first step is to open the serial port. This will use pyserial package which has to be imported to the script using this line. 😛
import serial

However if the package is missing then it can be downloaded from the https://pypi.python.org/pypi/pyserial Read the rest of this entry

PyQt4: Getting into depth

Now let us add some functionalities to the window generated. For that, I am listing the APIs to create any widget and handling signals & slots:

To create any widget:

1. textbox=QtGui.QTextBox(“content of the text box”)

Note:This will work fine unless until you need to access this textbox in some function treating it as a global variable. To avoid the errors in future, use this line:

self.textbox=QtGui.QTextBox(“content of the text box”)

adding self in beginning will make textbox an attribute of the window under which it is created.

2. self.label=QtGui.QLabel(“content of the label”)

3. self.pushbutton=QtGui.QPushButton(“text on pushbutton”)

to create singnals and slots:

This can be achieved in two ways:
1.New version API- QtCore.QObject.Connect method:
QtCore.QObject.Connect(<name of the object generating signal>,QtCore.SIGNAL(“<signal name>”), <slot>)

Example:

QtCore.QObject.Connect(self.pushbutton,QtCore.SIGNAL(“clicked()”),   self.on_pushbutton_click) Read the rest of this entry

PyQt4: Displaying Windows

While coding in PyQt, one should be little familiar with both the python language and Qt Gui programming.

How to write a minimal skeleton code:
First we have to add the following line to the script to avoid writing python for executing each script 😛
#!/usr/bin/python

Thereafter all the necessary modules will have to be imported. sys is needed to initialise the QApplication. QApplication is a kind of parent application in which all the GUI components work. According to Qt documentation-

“The QApplication class manages the GUI application’s control flow and main settings. It contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application’s initialization and finalization, and provides session management. It also handles most system-wide and application-wide settings. For any GUI application that uses Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any time.”

QtGui is needed here if we want to display widget. If no widget is to be displayed then this line can be dropped.

import sys
from PyQt4 import QtGui

The main() function in C is analogous to the following line in python:

if __name__==’__main__’:
a=QtGui.QApplication(sys.argv)
# this will create an application named ‘a’initialised with a command-line parameter.

sys.exit(a.exec_())
#application is executed.

Now if we want to display any widget or window, we have to write it between the above two lines.

widget=QtGui.QWidget()
widget.setWindowTitle(‘simple’)
widget.show()

Running the final code will display a Widget.

#!/usr/bin/python

import sys
from PyQt4 import QtGui

if __name__==’__main__’:
a=QtGui.QApplication(sys.argv)

widget=QtGui.QWidget()
widget.setWindowTitle(‘simple’)
widget.show()
sys.exit(a.exec_())

helloworld

Introduction to PyQt: light-weight cross-platform Solution for Qt

While i was getting handy with Qt, came the problem of porting the application to the other platforms. For me, the main aim while jumping in Qt application development is to make the application run on embedded boards like mini2440, Raspi etc. and this time the board was Raspberry Pi.
There was some UI based project to be ported to Raspi, which required the cross-compiling of whole QT IDE for the Raspi, and i got something called qtonpi. Which, i felt, would require some tedious long hours, which i didn’t have.
Probably you will get this in my next blog on Qt.
But for now, there was another option called (drums beat…) PyQt. 😛

PyQt
PyQt

Easy and light weight PyQt. it worked as magic. Almost every linux distribution has python installed and all you need is a PyQt dev-kit, which basically binds the Qt APIs to the python. It is really a light-weight package which can be easily installed in almost all linux-distros in all architectures.
Lets get started:

Setting the work environment and installations: 

The dev-kit can be found in synaptic manager or at terminal by typing:-

$sudo apt-get install pyqt4-dev-tools Read the rest of this entry

Serial Port Interfacing In Qt

Well, for an embedded system guy, serial port is one of the most popular way to make your PC communicate with a target board, be it SBC or some serial based automation sort of work. Now, challenge is to use your own serial terminal software 😛 Well that’s the least what can be expected from a Qt Application developer.

Gui for the application

So this post is all about building an application which opens a serial port, and communicate with it.  Read the rest of this entry

Qt: Hello World

So here is the most basic application of Qt: Printing HELLO WORLD !!!!!!

There are two ways of accomplishing that:

  • using Qt- Creator IDE
  • using terminal and creating our generating makefile

First the easy one 😛

  1. Using GUI method:-

First create new QT-console project. (console simply means the output will be in form of a console).

name the project as HELLO.and just click next buttons with the default setting of version control and all those stuffs.. Finally you endup with a screen like this: Read the rest of this entry

Qt: Introduction

Hii friends, this time i am going to share my little knowledge about Qt… i.e.. what is Qt, why it is used, and (obviously) how it is used 😛 Later on, in the successive blogs, I will show how to write applications in Qt.

Qt is basically a cross-platform c++ based application framework. Cross-

QT

platform means that the code you write on one platform (ex. Linux) can get compiled easily on another platform (ex. Linux). Qt is mainly used for designing GUI (graphical user interface ) applications and some non-GUI application like console for servers. Qt finds its application in VLC media player, AutoDesk Maya, Fedora(KDE framework), Mathematica, OPERA MINI (upto version 10.0). The companies using Qt comprises of NOKIA, Samsung, Google (google server consoles), Research In Motion etc. Read the rest of this entry

RaspberryPi Basics: Part I-GPIO usage

So, this time we are having Raspberry Pi, to experiment with, WooooOO!

Thanks to Vinay Chaddha Sir, for this.  Actually I have to show some prototype model based on the single board computers and I dont see anything cheaper than RaspberryPi.  I actually need 8-10 of them but the one I ordered is still pending 😦 and said to be delievered in November. Ughhhhh….

After the ‘incident less accident’ scene with the Beaglebone, we were sort of 😦 but still no matter, it is sent to Beagle Hospital for repair.

What is a Raspberry Pi ??   ( I will call it RasPi)

As they say it,. “The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming”.

So, RasPi has got quite a few interesting things, 😉 2 USB ports, an HDMI connector, a SD card socket for storage, an audio jack, and the best thing I like is the RCA video jack.  For all those like me those, who dont have a HDMI or DVI connector Monitor or LCD TV, thats where a
RCA video jack is something which is  Awesome.

Read the rest of this entry