a. U
ntuk menginstall Qt designer, dapat didownload pada mirror ke
http://kebo.vlsm.org
56
b. M
emulai Qt designer
Gambar 3.7 Tampilan Qt designer
c. K
lik C++ untuk membuat project baru dan klik elipsis (..) untuk
project file line edit dimana tempat menyimpan project dan
filename (filename.pro)
57
Gambar 3.8 Tampilan membuat project baru
d. K
lik File | New, pilih dialog untuk membuat New File Dialog
Gambar 3.9 Tampilan membuat New File Dialog
e. K
lik File | New, pilih C++ main file untuk membuat file main.cpp
g. K
lik Edit | Connection untuk mengkoneksikan widget dan klik New
untuk New Connection
59
Gambar 3.12 Tampilan mengkoneksikan widget
h. K
lik Edit Slot untuk masuk ke Edit Functions dialog dan klik New
Function untuk menambahkan new slot
Gambar 3.13 Tampilan menambah new slot
i. K
lik “file.ui.h” pada project overview program untuk masuk ke
editor program
60
Gambar 3.14 Tampilan code editor
Tampilan program aplikasi ini adalah :
Gambar 3.15 Tampilan program aplikasi
Main.cpp
#include <qapplication.h>
#include "wireless.h"
wireless.ui
#include <qtabdialog.h>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <qprocess.h>
#include <qpixmap.h>
#include <qobject.h>
#include <qtimer.h>
#include <qmessagebox.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
char iface[5];
char iface2[5];
QTimer *internalTimer;
QTimer *internalTimer2;
QProcess *proc;
//QProcess *proces;
void wireless::coba()
{
QPixmap p;
p.load("apple_blue.png");
apple->setPixmap(p);
char line[255];
char status [3];
float link = 0;
float level = 0;
float noise = 0;
int nwid = 0;
int crypt = 0;
int misc = 0;
int mode = 0;
int loop = 1;
float level2 = 0;
float noise2 = 0;
QPixmap pm;
level2=level - 256;
noise2=noise - 256;
strncpy(iface2, iface, 5);
interface->setText( QString ( iface2 ));
// lineEdit3->setText( QString::number( link, 'f', 2 ) );
level_quality->setText( QString::number( level2, 'f', 0 ) );
noise_quality->setText( QString::number( noise2, 'f', 0 ) );
if ( link > 90 )
{
pm.load( "excellent.png" );
tampil->setText("excellent");
pixmapLabel2->setPixmap( pm );
}
else if ( link > 80 )
{
pm.load( "good.png" );
tampil->setText("good");
pixmapLabel2->setPixmap( pm );
}
else if ( link > 60 )
{
pm.load( "marginal.png" );
tampil->setText("marginal");
pixmapLabel2->setPixmap( pm );
}
else if ( link > 40 )
{
pm.load( "oor_down.png" );
tampil->setText("oor_down");
pixmapLabel2->setPixmap( pm );
}
else if ( link > 20 )
{
pm.load( "oor_minimum.png" );
tampil->setText("oor_minimum");
pixmapLabel2->setPixmap( pm );
}
else if ( link == 0 )
{
pm.load( "offline.png" );
tampil->setText("offline");
pixmapLabel2->setPixmap( pm );
}
}
/* Print channel information, and signal ratio */
}
else {
//printf ("Wirless device /proc/net/wireless not found\nEnable radio
networking and recompile your kernel\n");
}
}
void wireless::coba2()
{
internalTimer2 = new QTimer( this ); // create internal timer
connect( internalTimer2, SIGNAL(timeout()), SLOT(setupTab2()) );
// connect( internalTimer, SIGNAL(timeout()), SLOT(setupTab3()) );
internalTimer2->start( 10000 );
}
void wireless::setupTab2()
{
}
void wireless::readFromStdout()
{
//QString coba;
// coba = QString ( proc->readStdout() );
// textEdit2->setText( coba );
//textEdit2->append( proc->readStdout() );
// textBrowser1->setText( proc->readStdout() );
//textEdit3->clear();
textEdit3->append( proc->readStdout() );
}
void wireless::ngeset()
{
char copy[100];
QString input=QString ( essid->text() );
strcpy(copy, input);
//QString input=essid->text();
char ch[255];
sprintf(ch,"iwconfig wlan1 essid %s",copy);
system(ch);
}