FontDialog QML Type
ネイティブフォントダイアログ。もっと見る...
Import Statement: | import Qt.labs.platform |
Inherits: |
プロパティ
- currentFont : font
- font : font
- options : flags
詳細な説明
FontDialog型は、ネイティブプラットフォームのフォントダイアログ用のQML APIを提供します。
フォントダイアログを表示するには、FontDialogのインスタンスを作成し、必要なプロパティを設定し、open ()を呼び出します。currentFont プロパティを用いて、ダイアログ内で現在選択されているフォントを決定することができます。font プロパティは、ダイアログを受け入れることによって最終的な選択が行われた後にのみ更新されます。
MenuItem { text: "Font" onTriggered: fontDialog.open() } FontDialog { id: fontDialog currentFont.family: document.font } MyDocument { id: document font: fontDialog.font }
利用可能性
ネイティブプラットフォームフォントダイアログは、現在以下のプラットフォームで利用可能です:
- iOS
- Linux(GTK+プラットフォームテーマで動作している場合)
- macOS
Qt Labs Platform モジュールは、利用可能なネイティブ実装がないプラットフォームでのフォールバックとしてQt Widgets を使用します。したがって、Qt Labs Platform モジュールの型を使用するアプリケーションは、QtWidgets にリンクし、QGuiApplication の代わりにQApplication を使用する必要があります。
QtWidgets ライブラリにリンクするには、qmake プロジェクトファイルに以下を追加します:
QT += widgets
main()
にQApplication のインスタンスを作成します:
#include <QApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
注意: Qt.labs モジュールの型は、将来のバージョンでも互換性が保たれることを保証するものではありません。
プロパティ Documentation
currentFont : font |
font : font |
このプロパティは、最終的に受け入れられたフォントを保持する。
currentFont プロパティとは異なり、font
プロパティは、ユーザーがダイアログ内でフォントを選択している間は更新されず、最終選択が行われた後にのみ更新されます。つまり、ユーザーがフォントを受け入れるためにOK をクリックしたときです。あるいは、accepted() シグナルを処理して、最終的な選択を取得することもできます。
currentFont およびaccepted()も参照してください 。
options : flags |
このプロパティは、ダイアログのルック&フィールに影響する様々なオプションを保持します。
デフォルトでは、すべてのオプションは無効になっています。
オプションはダイアログを表示する前に設定する必要があります。ダイアログが表示されている間にオプションを設定しても、ダイアログに即座に反映されるとは限りません(オプションやプラットフォームによって異なります)。
利用可能なオプション
定数 | 説明 |
---|---|
FontDialog.ScalableFonts | スケーラブルフォントを表示する。 |
FontDialog.NonScalableFonts | 非スケーラブルフォントを表示。 |
FontDialog.MonospacedFonts | 等幅フォントを表示する。 |
FontDialog.ProportionalFonts | プロポーショナルフォントを表示する。 |
FontDialog.NoButtons | OK とCancel ボタンを表示しない(「ライブ・ダイアログ」に便利)。 |
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.