EX NO:3b
GUI PROGRAMMING USING QT TOOLKIT
17.07.12
AIM
To write a simple GUI program using QT toolkit
PREREQUISITE:
C/C++
- QT
INTRODUCTION:
Qt is a cross-platform application
development framework. Some of the well known applications developed
with Qt are KDE, Opera, Google Earth and Skype. Qt was first publicly
released on May 1995. It is dual licensed. That means, it can be used
for creating open source applications as well as commercial ones. Qt
toolkit is a very powerful toolkit. It is well established in the
open source community
GUI
programs using the Qt toolkit:
To
install Qt Toolkit:
[root@localhost
Desktop]# yum install qt-devel qt-demos qt-examples qt-doc
Loaded
plugins: langpacks, presto, refresh-packagekit
Adding
en_US to language list
Setting
up Install Process
Package
1:qt-devel-4.7.4-7.fc14.i686 already installed and latest version
Package
1:qt-demos-4.7.4-7.fc14.i686 already installed and latest version
Package
1:qt-examples-4.7.4-7.fc14.i686 already installed and latest version
Package
1:qt-doc-4.7.4-7.fc14.noarch already installed and latest version
Nothing
to do
Follow
the steps to write a simple hello world program:
[root@localhost
Desktop]# mkdir qthello
[root@localhost
Desktop]# cd qthello
[root@localhost
qthello]# vi qthello.cpp
PROGRAM:
#include <qapplication.h>
#include <qpushbutton.h>
#include <qpushbutton.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
a.setMainWidget( &hello );
hello.show();
return a.exec();
}
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
a.setMainWidget( &hello );
hello.show();
return a.exec();
}
[root@localhost
qthello]# vi qthello.pro
[root@localhost
qthello]# qmake -o Makefile qthello.pro
[root@localhost qthello]# make
g++
-c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
-march=i686 -mtune=atom -fasynchronous-unwind-tables -DQT_NO_DEBUG
-DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT
-I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -o
qthello.o qthello.cpp
g++
-o qthello qthello.o -L/usr/lib/qt-3.3/lib -lqt-mt -lXext -lX11
-lm
[root@localhost
qthello]# ./qthello
Session
management error: None of the authentication protocols specified are
supported
RESULT
Thus ,using qt
toolkit a button had been created and the output was verified.
No comments:
Post a Comment