| ホーム · All Namespaces · 全てのクラス · 主要なクラス · グループ別クラス · Modules · 関数一覧 |
[前へ: The New Qt Designer] [ホーム] [次へ: Qt 4 データベース GUI レイヤ]
Qt 4 を使うことで、開発者は視覚その他に障害を持ったユーザが利用可能となるクロスプラットフォームのアプリケーションを書ける. Qt のアクセシビリティ機能は、より多くのユーザに対してアプリケーションを利用可能とし、アクセシビリティへの対応がしばしば要求される政府関係の市場への参入を視野に入れることができる.
The accessibility classes have been extended in various ways since Qt 3. We added new functions and new enum values, and revised the API to make it more consistent with the rest of Qt. We also added two properties to QWidgetに accessibleName と accessibleDescriptionの2つのプロパティを追加することで、コードを記述することなく基本的なヘルプテキストを Qt Designer 内で設定できるようにした.
Qt のアクセシビリティに関するアーキテクチャは以下のとおりである. Qt は1つの包括的なインターフェース QAccessibleInterface, that can be used to wrap all widgets and objects (e.g., QPushButton) をラップすることが出来る。この単一インターフェースは、補助テクノロジにおいて必要とされる全てのメタデータを提供する. Qt は組み込みウィジェットに対するこのインターフェースの実装を、プラグインの形態で提供している.
A more detailed overview of the accessibility support in Qt can be found on the Accessibility page.
By default, Qt applications are run with accessibility support enabled on Windows and Mac OS X. On Unix/X11 platforms, applications must be launched in an environment with the QT_ACCESSIBILITY variable set to 1. For example, this is set in the following way with the bash shell:
export QT_ACCESSIBILITY=1
Accessibility features are built into Qt by default when the libraries are configured and built.
カスタムのウィジェットを開発する際には、 QAccessibleInterface のカスタムサブクラスを作って ( QAccessiblePluginを使用して)pluginの形で配布するか,あるいはコンパイルしてアプリケーションに含めることになる. Qt に元々用意されているアクセシビリティサポートも同様に,pluginの形にビルドして使う(デフォルト)か,あるいは,Qt ライブラリに直接組み込んで使うことができる. pluginを使うことで得られる主な利点としては,アクセシビリティのクラスは利用に際してメモリへとロードされるようになるので,補助テクノロジが利用されない限り,動作が遅くなったりしないところである.
QAccessibleInterfaceに加えて、 Qt では2つの便利なクラス QAccessibleObject と QAccessibleWidget, that provide the lowest common denominator of metadata (e.g., widget geometry, window title, basic help text). You can use them as base classes when wrapping your custom QObject や QWidget のサブクラスでアクセシビリティ機能を使いたい場合には、これらを基本クラスとして使うとよい.
Qt 4 における他の新機能としては、既に定義されているものに加え、他のバックエンドをサポートできるようになったことが挙げられる. これは QAccessibleBridgeをサブクラス化することで実現できる.
最初の例では、カスタムウィジェットにアクセシビリティの情報を提供する方法について解説する. 基本クラスに QAccessibleWidget を利用して、色々な関数を再実装することができる:
class MyWidgetInterface : public QAccessibleWidget
{
public:
MyWidgetInterface(QWidget *widget, Role role);
QString text(Text text, int child) const;
State state(int child) const;
QString actionText(int action, Text text, int child) const;
bool doAction(int action, int child, const QVariantList ¶ms);
...
};
これは、ユーザがオブジェクトのデフォルトアクションあるいは "press" をおこなった際に、ラップされた MyWidget オブジェクトの click() という関数を呼び出すようにする doAction() 関数の実装である。
bool MyWidgetInterface::doAction(int action, int child,
const QVariantList ¶ms)
{
if (child || !widget()->isEnabled())
return false;
switch (action) {
case DefaultAction:
case Press:
{
MyWidget *widget = qobject_cast<MyWidget *>(object());
if (widget)
widget->click();
}
return true;
}
return QAccessibleWidget::doAction(action, child, params);
}
ウィジェットインターフェースをプラグインとしてエクスポートするには、 QAccessibleFactory をサブクラス化する必要がある:
QStringList MyFactory::keys() const
{
return QStringList() << "MyWidget" << "MyOtherWidget";
}
QAccessibleInterface *MyFactory::create(const QString &className,
QObject *object)
{
if (classname == "MyWidget")
return new MyWidgetInterface(object);
if (classname == "MyOtherWidget")
return new MyOtherWidgetInterface(object);
return 0;
}
Q_EXPORT_PLUGIN2(myfactory, MyFactory)
[前へ: The New Qt Designer] [ホーム] [次へ: The Qt 4 Database GUI Layer]
| Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.5.0 |