#include <qpe/qpeapplication.h> // 使用するクラスを指定する #include "mainwindow.h" // 使用するプログラムを指定する int main(int argc, char *argv[]) { QPEApplication a(argc,argv); Mainwindow *mw = new Mainwindow(); a.showMainWidget(mw); return a.exec(); }
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> // 使用するクラスを指定する #include <qapplication.h> #include <qpushbutton.h> #include <qtextcodec.h> #include <qfont.h> class Mainwindow : public QWidget{ Q_OBJECT public: Mainwindow(QWidget *parent = 0, const char *name = 0); private: QTextCodec *codec; // テキストコーデック QPushButton *button; // ボタン }; #endif //MAINWINDOW_H
#include "mainwindow.h" // mainwindow.cpp のヘッダーファイル mainwindow.h を読み込み Mainwindow::Mainwindow(QWidget *parent, const char *name) : QWidget(parent, name) { // テキストコーデック「codec」を作成 // 以降、codec->toUnicode("ここに書いたことは日本語で表示できる") codec = QTextCodec::codecForName("ShiftJIS"); // ウィンドウのタイトルを設定 setCaption(codec->toUnicode("サンプル1「ウィンドウを作成する」")); // 使用するフォントを設定 QFont f("lcfont",18); setFont(f); // ボタン「button」を作成(「Quit」と表示されたボタン) button = new QPushButton(codec->toUnicode("Quit"), this); // ボタン「button」の配置位置を指定 setGeometry(配置x座標,配置y座標,ボタンの横幅,ボタンの縦幅) button -> setGeometry(200, 80, 70, 25); // 「button」が「clicked()(=押した)」されたら「qApp(=アプリケーション)」に対して「quit()(=終了)」を実行させる QObject::connect( button, SIGNAL(clicked()), qApp, SLOT(quit()) ); }
. ~/SLZaurus/bin/dev-arm-qpe.sh cd ~/SLZaurus/sample0001 progen -o sample0001.pro tmake -o Makefile sample0001.pro make |