IGOS Nusantara dan Qt: Perbedaan revisi
Dari IGNwiki
								
												
				| (11 revisi antara oleh pengguna yang sama tidak ditampilkan) | |||
| Baris 1: | Baris 1: | ||
| − | == Pasang ==  | + | Pengguna IGOS Nusantara dapat membuat program memakai Qt  | 
| + | |||
| + | == Pasang Qt ==  | ||
  #  |   #  | ||
| + |  yum -y install gcc-c++  | ||
  yum -y install qt qt-devel  |   yum -y install qt qt-devel  | ||
| − | == Contoh Non GUI ==  | + | == Contoh Program ==  | 
| − | Simpan di: /home/igos/qt/qtDunia.cpp  | + | |
| + | === Qt Non GUI ===  | ||
| + | Simpan di: /home/igos/qt/'''qtDunia.cpp'''  | ||
  $    |   $    | ||
| Baris 13: | Baris 18: | ||
Ketik:  | Ketik:  | ||
| + | |||
  #include<QtCore>  |   #include<QtCore>  | ||
  int main(){  |   int main(){  | ||
| Baris 18: | Baris 24: | ||
  }  |   }  | ||
| − | ==   | + | === Qt GUI ===  | 
| − | Simpan di: /home/igos/qt/qtGuiDunia1.cpp  | + | Simpan di: /home/igos/qt/'''qtGuiDunia1.cpp'''  | 
  $  |   $  | ||
  cd /home/igos/qt  |   cd /home/igos/qt  | ||
  nano qtGuiDunia1.cpp  |   nano qtGuiDunia1.cpp  | ||
| + | |||
| + | Ketik:  | ||
  #include<QApplication>  |   #include<QApplication>  | ||
| Baris 31: | Baris 39: | ||
     QApplication a(argc, argv);  |      QApplication a(argc, argv);  | ||
     QLabel    label;  |      QLabel    label;  | ||
| − |      label.setText("  | + |      label.setText("Halo Dunia1");  | 
     label.show();  |      label.show();  | ||
     a.exec();  |      a.exec();  | ||
  }  |   }  | ||
| − | Simpan di: /home/igos/qt/qtGuiDunia2.cpp  | + | Simpan di: /home/igos/qt/'''qtGuiDunia2.cpp'''  | 
  $  |   $  | ||
  cd /home/igos/qt  |   cd /home/igos/qt  | ||
  nano qtGuiDunia2.cpp  |   nano qtGuiDunia2.cpp  | ||
| + | |||
| + | Ketik:  | ||
  #include <QApplication>  |   #include <QApplication>  | ||
| Baris 49: | Baris 59: | ||
     QApplication app (argc, argv);  |      QApplication app (argc, argv);  | ||
| − |      QPushButton button ("  | + |      QPushButton button ("Halo Dunia2");  | 
     button.show();  |      button.show();  | ||
| Baris 56: | Baris 66: | ||
== Kompilasi ==  | == Kompilasi ==  | ||
| + | Kompilasi qtDunia.cpp  | ||
  $  |   $  | ||
  g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtDunia.cpp -o qtDunia  |   g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtDunia.cpp -o qtDunia  | ||
| + | |||
| + | Kompilasi qtGuiDunia2.cpp  | ||
| + |  $  | ||
| + |  g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtGuiDunia2.cpp -o qtGuiDunia2  | ||
== Jalankan ==  | == Jalankan ==  | ||
  $  |   $  | ||
  ./qtDunia  |   ./qtDunia  | ||
| + |  ./qtGuiDunia2  | ||
| + | |||
| + | == Referensi ==  | ||
| + | * https://qt-project.org/wiki/Qt_for_beginners_Hello_World  | ||
| + | * http://www.informit.com/articles/article.aspx?p=1405223  | ||
Revisi terkini pada 27 Agustus 2014 02.45
Pengguna IGOS Nusantara dapat membuat program memakai Qt
Daftar isi
Pasang Qt
# yum -y install gcc-c++ yum -y install qt qt-devel
Contoh Program
Qt Non GUI
Simpan di: /home/igos/qt/qtDunia.cpp
$ cd /home/igos mkdir qt cd qt nano qtDunia.cpp
Ketik:
#include<QtCore>
int main(){
   qDebug() << "Halo Dunia\n";
}
Qt GUI
Simpan di: /home/igos/qt/qtGuiDunia1.cpp
$ cd /home/igos/qt nano qtGuiDunia1.cpp
Ketik:
#include<QApplication>
#include<QLabel>
int main(int argc, char *argv[]){
   QApplication a(argc, argv);
   QLabel    label;
   label.setText("Halo Dunia1");
   label.show();
   a.exec();
}
Simpan di: /home/igos/qt/qtGuiDunia2.cpp
$ cd /home/igos/qt nano qtGuiDunia2.cpp
Ketik:
#include <QApplication>
#include <QPushButton>
int main(int argc, char **argv)
{
   QApplication app (argc, argv);
    
   QPushButton button ("Halo Dunia2");
   button.show();
    
   return app.exec();
}
Kompilasi
Kompilasi qtDunia.cpp
$ g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtDunia.cpp -o qtDunia
Kompilasi qtGuiDunia2.cpp
$ g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtGuiDunia2.cpp -o qtGuiDunia2
Jalankan
$ ./qtDunia ./qtGuiDunia2