IGOS Nusantara dan Qt: Perbedaan revisi
Dari IGNwiki
								
												
				 (→Kompilasi)  | 
				|||
| Baris 58: | Baris 58: | ||
== Kompilasi ==  | == Kompilasi ==  | ||
| + | Kompilasi program1  | ||
  $  |   $  | ||
  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 program2  | ||
| + |  g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtGuiDunia2.cpp -o qtGuiDunia2  | ||
== Jalankan ==  | == Jalankan ==  | ||
  $  |   $  | ||
  ./qtDunia  |   ./qtDunia  | ||
Revisi per 27 Agustus 2014 02.34
Pasang
# 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
#include<QApplication>
#include<QLabel>
int main(int argc, char *argv[]){
   QApplication a(argc, argv);
   QLabel    label;
   label.setText("Hello World");
   label.show();
   a.exec();
}
Simpan di: /home/igos/qt/qtGuiDunia2.cpp
$ cd /home/igos/qt nano qtGuiDunia2.cpp
#include <QApplication>
#include <QPushButton>
int main(int argc, char **argv)
{
   QApplication app (argc, argv);
    
   QPushButton button ("Hello world !");
   button.show();
    
   return app.exec();
}
Kompilasi
Kompilasi program1
$ g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtDunia.cpp -o qtDunia
Kompilasi program2
g++ -I/usr/include/QtCore -I/usr/include/QtGui -lQtGui -lQtCore qtGuiDunia2.cpp -o qtGuiDunia2
Jalankan
$ ./qtDunia