2012/09/24 21時ごろ修正
概要
「Qt(キュート)」はノキア digia が開発している、クラスプラットフォームなGUIツールキット。
ライセンスは「GPL」と「LGPL」から選択できる。
Linux で GUI アプリを作成する場合、GTK か Qt を利用することが多い。GTK は Mac 上だといまいちなので、Qt を Mac 上で利用方法を簡単にメモしておく。
注意点
最初からちょっとがっかりだが、Qt は Mac OS X 10.8 Mountain Lion にまだ完全対応していない。10.8対応はもうしばらく待つ必要がある。 4.8.3 から Mac OS X 10.8 に対応した。
インストール
「Download Qt for Open Source C++ development on Mac OS X — Qt - A cross-platform application and UI framework」 「Qt Developer Network」から最新版 dmg をダウンロードする。この記事を書いている時点では「4.8.2」 記事修正時点での最新版は「4.8.3」。
インストール場所の確認
以下のように様々な物がインストールされる。
- Qt Creator, Qt Designer, Qt Linguist:「/Developer/Applications/Qt」
- Qt Documentation:「/Developer/Documentation/Qt」
- Qt Examples:「/Developer/Examples/Qt」
- Qt Plugins:「/Developer/Applications/Qt/Plugins」
- Qt Frameworks:「/Library/Frameworks」
- Qt Libraries:「/usr/lib」
- qmake, moc, uic, etc.:「/Developer/Tools/Qt (symlink to /usr/bin)」
- Uninstall script:「/Developer/Tools/uninstall-qtsdk.py」
ドキュメント
「Getting Started Programming with Qt | Documentation | Qt Developer Network」とか「Qt Creator」とかを見るとアプリの作成方法が書いてある。
動作確認
動作確認のために簡単なアプリを作成してみる。
Qt Creatorを使うのが本来は簡単だが、ここではソースからビルドしてみる。
以下のようなソースを書く。
#include <QApplication>
#include <QTextEdit>
int main(int argv, char **args)
{
QApplication app(argv, args);
QTextEdit textEdit;
textEdit.show();
return app.exec();
}
ビルド、起動は Terminal で以下のようにする。
qmake -project
qmake
xcodebuild
open build/Release/sample.app
以下のようにウィンドウが起動する。
文字は後で入力している。
まとめ
簡単にインストールと使い方だけ書いた。
さらに詳細を知りたい場合は、本家のドキュメントがかなり充実しているので、そちらを見ると良い。