最初の一歩HelloWorld
- ディレクトリを作成する
- プログラムを作成する
- プロジェクトファイルをさくせいする
- コンパイルを実行
- 実行
- hello/hello.cpp
- #include <qapplication.h>
- #include <qlabel.h>
-
- int main( int argc, char *argv[] )
- {
- QApplication myapp( argc, argv );
-
- QLabel *mylabel = new QLabel( "Hello World!!", 0 );
- mylabel->resize( 80, 30 );
-
- // myapp.setMainWidget( mylabel ); // 閉じるボタンを押したときアプリ終了(Qt3)
- mylabel->show();
-
- return myapp.exec();
- }
-
$ mkdir hello $ cd hello $ vi hello.cpp コーディング $ qmake -project プロジェクトファイル生成(hello.pro) $ qmake $ make コンパイル完了 $ ./hello
実行結果

メモ
myapp.setMainWidget( mylabel );
というような記述はQt4では不要みたい。
プロジェクトファイル名や実行ファイル名は上のディレクトリ名が使われているみたい。
以上
添付ファイル