network programming with qt (c++)

15
Network Programming with Qt Manohar Kuse [email protected] http://ihome.ust.hk/~mpkuse

Upload: manohar-kuse

Post on 05-Jul-2015

309 views

Category:

Engineering


9 download

DESCRIPTION

A quick-start quide to network programming in Qt. The related toy-code can be access from the website http://kusemanohar.wordpress.com/2014/03/26/qt-network-programming/ If you are looking for a Qt tutorial (GUI), look here : http://kusemanohar.wordpress.com/2012/08/19/qt-beginners-tutorial/

TRANSCRIPT

Page 1: Network programming with Qt (C++)

Network Programmingwith Qt

Manohar [email protected]://ihome.ust.hk/~mpkuse

Page 2: Network programming with Qt (C++)

What is Qt

● C++ Library ○ Gives extra functions to C++

● Object Oriented● Cross Platform

○ Windows, Linux, Mac, Android● Developed by Nokia (now by Qt-project.org)

Official Site : http://qt-project.org/

Page 3: Network programming with Qt (C++)

What can I do with Qt ?

● Build GUIs (Graphical User Interfaces)● Network Programming● Handling Databases (like MySQL,Oracle etc)● Multi-threaded programming● Graphics for computer games (OpenGL)

Page 4: Network programming with Qt (C++)

Which Software use Qt Libraries ?

http://en.wikipedia.org/wiki/Category:Software_that_uses_Qt

Page 5: Network programming with Qt (C++)

Learning QtMy Tutorial

● http://kusemanohar.wordpress.com/2012/08/19/qt-beginners-tutorial/BooksThe famous ones

● http://catalog.ust.hk/catalog/archives/734729● http://catalog.ust.hk/catalog/archives/645062

Other Books● http://catalog.ust.hk/catalog/search/Qt

Youtube● http://www.youtube.com/playlist?list=PL2D1942A4688E9D63

Other useful guides● http://qt-project.org/resources/getting_started● http://qt-project.org/wiki/developer-guides

Page 6: Network programming with Qt (C++)

My suggestion

1. Install Qt Creator on your PC/Mac/Linux2. Understand today’s toy project3. Go through my tutorial.

http://kusemanohar.wordpress.com/2012/08/19/qt-beginners-tutorial/

If you still want to learn more follow a book from library

Page 7: Network programming with Qt (C++)

Installation● I also have a section on Qt Installation in my tutorial

● In case you are installing on windows make sure you have C/C++ compiler installed. ○ Either of Visual Studio or MinGW

● Download Qt from : http://qt-project.org/downloads

Page 8: Network programming with Qt (C++)

Today’s Toy Project

Page 9: Network programming with Qt (C++)

What the Toy Project should do?

A GUIAn input field for your nameButton (Say Hi)Pop-upGreeting on the application

Page 10: Network programming with Qt (C++)

Demonstration

I have put this demonstration on youtubehttp://www.youtube.com/watch?v=dcjgzlezwE0

Page 11: Network programming with Qt (C++)

Things to Take away● Know how to create a Qt project● Know how to create a GUI form● Understand what I mean with event programming● Understand connect() in Qt● Understand how to retrive text from lineEdit and how to write text on the

application○ QString input = ui->lineEdit->text();○ ui->label->setText( input + QString( “this is appended” ) );

Page 12: Network programming with Qt (C++)

Network Programming with Qt

Page 13: Network programming with Qt (C++)

Client - Server Model

1. Connect to server2. Event-1 : Send data3. Event-2 : Receive data4. repeat

1. Start listening on a port2. Event-1 :Incoming connection3. Event-2 :accept connection4. Event-3 :

a. Receive data from client,b. Process this datac. Send this as response

Page 14: Network programming with Qt (C++)

Toy Network Project

Aim : Client sends some text to the server. Server converts this to upper case and responds the same

Lets callKClientKServer

Page 15: Network programming with Qt (C++)

Demonstration of Toy Network Project

I have put this demonstration on youtubehttp://www.youtube.com/watch?v=EzQICMXvaxY

You can download the source code from https://dl.dropboxusercontent.com/u/28068989/Qt_Network.zip