Install Qt Components for Desktop

There are not so many components for QML. To use buttons, tabs, windows etc, you need Qt Components for Desktop.

Qt Labs blog article says that you can install Qt Components for Desktop with “qmake && make install”. But it is too difficult to understand for newbies like me. I’ll explain how to install.

# My environment is Linux. On Windows and Mac, not same way can be used.

First, download Qt Components for Desktop.

Open this URL and “download master as tar.gz” to download latest version. Using January 24 2012 version is  also good choice. I succeeded with this version.

# Of course you can download via git instead. Execute “git clone git://gitorious.org/qt-components/desktop.git”

Extract the tar.gz file. This time, extracted directory will be named as “qt-components-desktop”

Move to “qt-components-desktop” directory and check the contents with ls.

$ > cd /home/phanect/Desktop/qt-components-desktop
$ > ls
components  desktop.pro  desktop.qmlproject  examples  Makefile  qmldesktopviewer  README  src

Next, let’s compile and install.

At fitst, we have to execute qmake command. You should use qmake included in QtSDK. I failed to install when I use qmake provided by linux distributer. (openSUSE)

Just execute following command.

/home/phanect/bin/QtSDK/Desktop/Qt/4.8.0/gcc/bin/qmake

# I’m using Qt 4.8.0.

And, execute make install. This make command should be installed from system repository.

make install

Then see /home/phanect/bin/QtSDK/Desktop/Qt/4.8.0/gcc/imports/QtDesktop/ and you can find various files.

Then, you can use various components.

import QtQuick 1.1
import QtDesktop 0.1

Rectangle {
width: 360
height: 360

Button {

}
}

Write “import QtDesktop 0.1″ to use components.

Qt Developer Conference Tokyo 2011

I’ve been Qt Developer Conference Tokyo 2011(#qtdc_jp) at Akihabara UDX. I didn’t attend today’s GIS class to attend this event. :P It was so varuable today.

I exhibited KDE & Plasma Active with terucco, one of KDE JP members. Terucco brought his FreeBSD machine with KDE and I exhibited Plasma Active (… on VirtualBox on my netbook, not tablet)

And it was the first time to see @moguriso, @IoriAyane, @kenya888 offline.

After the exhibition and seminars, I took lightning talk about Plasma Active. I made a screencast of Plasma Active, and presented with it.
At least there were no critical problem, but I found some problem:

1. I modified video at last night, but I used old version by mistake.
I created it on my home computer and forgot to download it on my mobile PC, and @himamura kindly gave me his WiMAX access point so that I can download from my dropbox. But I forgot… Sorry, @himamura… I waste your kindness… OTL
Anyway, preparation should be done sooner.

2. Not attractive for people who are interested in their business
I’ve believed it must be interesting for audience to see the demo, and boring to just listen to my explanation only with the text-based slides. So I just showed 2 slides to tell “Plasma active is a tablet UI” and almost all explanation was with demo video.
However, audience come to QtDC to improve their business, so I should tell them it is useful for their business at first. I planned to explain that “it is supported by two German company and useful for your business” at the last slide, but I ran out of the time and couldn’t.
It is important to consider audience’s character and interest.

We had a party after the event, and after that, some Nokia staffs and exhibiters had another party.
Fortunately I had a seat by Lars Knoll, the chief maintainer of Qt. I talked with him and Daniel Kihnberg (Qt Ecosystem Director) a lot.
I asked him relationship between QML and C++. As I thought, it is different from e.g. relationship between HTML and PHP. When you develop application with Qt Quick, C++ is used to create QML element, and module. (I don’t know module in Qt yet, so I may misunderstand him.)

I also asked him for plans about file processing method for QML. He answered it is not planned yet.

We also talked about English. It is difficult for Japanese to improve/keep English skill because there are few opportunity to talk in English in Japan. I think Europeans are generally better at English than Japanese because people don’t need passport to go other EU countries, and Lars agreed. But for example, German (Lars is from Germany) don’t have so many opportunities to talk in English and most books and documents are translated to German. There seems similar problem.

Lars also told me that people use English usually in small countries like Norway and Sweden. For example, Movies are in English and there are only Norwegian subtitles. That’s good environment.

It was great day. I appreciate all Qt DevCon staff to give us such a interesting opportunity.

Text Background color in QML

On Text element of QML, there is no background color property. So you have to use Rectangle element.

Rectangle {
    color: "#808080"
    Text {
        text: "Hello, World"
    }
    width: childrenRect.width
    height: childrenRect.height
}

The result is…

Git の使い方のメモ

だいぶ前に手嶋屋で川原さんが行ってくれた Git 勉強会のメモ。
自分用のメモなので結構乱雑ですがご容赦。

git clone git@github.com:jumpeiogawa/Test.git # github から引っ張ってくる
 git add file.c # ファイルを追加
git commit file.c # ファイルをローカルリポジトリにコミット

-v オプション

git commit -v file.c

diff を見ることができる。

エイリアス

~/.gitconfig で
[alias]
ci = commit -v
などとエイリアスを作ることができる。

git ci

と打つと、

git commit -v

が実行される。

github に上げるには、push コマンドを用いる

git push origin master

この origin の部分は送信先を表す。
origin というのは、clone 元の意味。
このコマンドは、厳密に書くと

git push git@github.com:jumpeiogawa/Test.git master

と書くことができる。
この origin が何を示すかについては、.git/config ファイルに記述してある。

[remote "origin"]
url = github.com:jumpeiogawa/Test.git master

という感じ。
master はブランチ名。省略することも可能。
逆に git サーバからローカルにダウンロードするには、

git pull origin master

つまり git server から repository を持ってきて編集し、サーバにあげるには、

git clone [git repository URL]
 [Edit by anyone else]
 git pull origin master
 [Edit by me: edit a.txt]
 git add a.txt
 git commit -v -m “commt message”
git push origin master

git log

git log と打つことで、

commit 5c075f4d0183414e5249e38bf9f82b99105df354
 Author: Taro Tanaka
 Date: Wed Nov 17 19:18:58 2010 +0900
 fixed the pre-member included to counted of the join-communities (fixes #1707)
 commit 3d4cf4d5f8ad7481317499621c919b825920f82f
 Author: Tajima Itsuro
 Date: Tue Nov 16 16:19:58 2010 +0900
 (fixes #1635) fixed term output with escape
(…以下略)

と、コミットログを表示することができる。


git reset [コミット番号]

で、指定したコミット番号の状態にまで、リポジトリの状態を戻すことができる。
コミット番号の代わりに

git reset “HEAD^”

とすると、一つ前の状態に戻すことができる。
^ は「ひとつ前」という意味。
HEAD は、最新の状態を表す。
以下のコミットログのうち一番最初の段落が HEAD

commit 5c075f4d0183414e5249e38bf9f82b99105df354
  Author: Taro Tanaka
  Date: Wed Nov 17 19:18:58 2010 +0900
  fixed the pre-member included to counted of the join-communities (fixes #1707)

commit 3d4cf4d5f8ad7481317499621c919b825920f82f
 Author: Jiro Yamada
 Date: Tue Nov 16 16:19:58 2010 +0900
 (fixes #1635) fixed term output with escape

commit 6f6369d69e056e437ce2d7e766d7ffa1c1f6e848
 Author: Saburo Suzuki
 Date: Mon Nov 8 20:49:33 2010 +0900
 (fixes #1676) Fixed NineTable calc bug.

commit 9b2f55d84ecb1e0cc2aa47a77b9b42f0582799f5
 Author: Taro Tanaka
 Date: Mon Nov 8 18:18:19 2010 +0900
 fixed non-array (fixes #1759)
(以下略)

つまり、
git reset “HEAD^” とすると、

commit 3d4cf4d5f8ad7481317499621c919b825920f82f
 Author: Tajima Itsuro
 Date: Tue Nov 16 16:19:58 2010 +0900
 (fixes #1635) fixed term output with escape

commit 6f6369d69e056e437ce2d7e766d7ffa1c1f6e848
 Author: ShinichiU
 Date: Mon Nov 8 20:49:33 2010 +0900
 (fixes #1676) Fixed NineTable calc bug.

commit 9b2f55d84ecb1e0cc2aa47a77b9b42f0582799f5
 Author: Masato Nagasawa
 Date: Mon Nov 8 18:18:19 2010 +0900
fixed non-array (fixes #1759)

のように、一番上の (最新の) コミットがコミットログが消える。
この時、ファイルは元に戻っていない。つまり、Nagasawa さんのコミットは、ファイルに反映されたままである。
このファイルに対する変更も元に戻すには、

git reset “HEAD^” --hard

とする。


フックスクリプト

コミットの前に実行されるシェルスクリプト
SVN では空ディレクトリをコミットできるが、git は空ディレクトリは削除される。
symfony では空ディレクトリに、0バイトのファイルをおいて、これに対処している。

ブランチ

ブランチを切って作業を始めて、作業中はブランチで、作業が完了してリリースしたかったらタグを切る
タグは、あるコミットに名前をつけているだけに過ぎないので、作業をするのは常にブランチかマスター。

Selenium テストケース作成で間違えやすいところ

仕事で Selenium のテストケースを書いています。
結構同じ間違いをよくするので、メモ。


ケース1: 画面遷移の後に、waitForPageToLoad をいれていない

×
$this->click(“//input[@value='はい']“); // ボタンをクリックして次のページに移動
$this->assertTrue($this->isElementPresent(“//*[@id=\"要素名\"]“));


$this->click(“//input[@value='はい']“);
$this->waitForPageToLoad(“30000″);
$this->assertTrue($this->isTextPresent(“テキスト”));

waitForPageToLoad を入れないと、次のページが読み込まれないうちに、isTextPresent (引数で与えられたテキストが存在するか否かを判定) が行われるため、上手く判定できません。


ケース2: 画面遷移がないのに、waitForPageToLoad をいれてしまう

×
$this->click(“link=削除”);
$this->waitForPageToLoad(“30000″);
$this->assertTrue($this->isElementPresent(“テキスト”));

$this->waitForPageToLoad(“30000″); // ×
$this->click(“//input[@value='はい']“);


$this->click(“link=削除”);
$this->waitForPageToLoad(“30000″);
$this->assertTrue($this->isElementPresent(“テキスト”));
$this->click(“//input[@value='はい']“);

よく見ると、二つ目の waitForPageToLoad の前には
$this->assertTrue($this->isElementPresent(“テキスト”)); が有りますが、これは画面遷移ではありません。画面遷移以外の処理の後にwaitForPageToLoad を行うと、タイムアウトしてしまいます。

Selenium Server が何故か勝手に起動している場合の終了方法

コマンドラインから Selenium Server を起動した際、以下のようなエラーが出る場合があります。

>java -jar selenium-server.jar
WARN – Failed to start: SocketListener0@0.0.0.0:4444
Exception in thread “main” java.net.BindException: Selenium is already running on port 4444. Or
 some other service is.
        at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:399)
        at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:234)
        at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:198)

既に Selenium RC Server は起動しています、とのことです。
これを解決するには、
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
にアクセスします。

OKOK

と表示されれば、Selenium Server が終了するはずです。

…が、なんか終了しない場合もありますね。

Selenium RC 1.0.3 で実行しました。

PHPUnit のインストールで詰まったこと

手嶋屋で Selenium によるテストを実行する際、PHPUnit が必要だったのですが、これのインストールで詰まったことを記しておきます。

問題1
pear パッケージマネージャがインストール出来ない。
普通は [PHP]/go-pear.bat を実行すればいいのですが、これにバグがある場合があるようです。
http://pear.php.net/go-pear.phar
の内容をコピーして貼りつけたのですが、動きません。
どうも、コピーしたのがまずかったようです。右クリックで保存して、そのファイルを上書きすべきだったようです。ていうかそもそもブラウザでひらくと、ファイルの最後のほうが文字化けしています。

問題2

PHP Warning:  PHP Startup: Unable to load dynamic library

$ >php phpunit
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Dev\PHP\ext\php_pdo_oci.dll' - 指定されたモジュールが見つかりません。 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Dev\PHP\ext\php_pdo_oci8.dll' -
指定されたモジュールが見つかりません。 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Dev\PHP\ext\php_pspell.dll' - 指
定されたモジュールが見つかりません。 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Dev\PHP\ext\php_sybase_ct.dll' -
指定されたモジュールが見つかりません。 in Unknown on line 0
(以下略)

と表示される。

これは、php.ini に

extension=php_pdo_oci
extension=php_pdo_oci8
...

と書いてある部分がコメントアウトされていなかったのが原因でした。

問題3

$ >php phpunit "file.php"
Could not open input file: phpunit

と表示される。

カレントディレクトリを PHP のインストールディレクトリ (C:\Program Files\PHP) に移して実行したら、普通に動きました。パス関係の問題である可能性が高いですが、未確認です。