FontsTab.qml
author sl
Tue, 27 May 2014 12:00:47 +0200
changeset 0 c0e13d2503b9
child 1 bc046f5187fd
permissions -rw-r--r--
First contribution.
Here is a basic QtQuick application based on Qt 5.3.
     1 import QtQuick 2.2
     2 import QtQuick.Controls 1.2
     3 import QtQuick.Dialogs 1.1
     4 
     5 Item {
     6     width: 640
     7     height: 480
     8     //SystemPalette { id: palette }
     9     clip: true
    10 
    11 
    12     //
    13     FontDialog {
    14         id: fontDialog
    15         visible: false
    16         modality: Qt.WindowModal
    17         scalableFonts: fontDialogScalableFonts.checked
    18         nonScalableFonts: fontDialogNonScalableFonts.checked
    19         monospacedFonts: fontDialogMonospacedFonts.checked
    20         proportionalFonts: fontDialogProportionalFonts.checked
    21         title: qsTr("Choose a font")
    22         font: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal })
    23         currentFont: Qt.font({ family: "Arial", pointSize: 24, weight: Font.Normal })
    24         onCurrentFontChanged: { console.log("CurrentFontChanged: " + currentFont) }
    25         onAccepted: { console.log("Accepted: " + font) }
    26         onRejected: { console.log("Rejected") }
    27     }
    28     //
    29 
    30     Flow {
    31         anchors.fill: parent
    32         anchors.margins: 12
    33         spacing: 10
    34 
    35         CheckBox {
    36             id: fontDialogScalableFonts
    37             text: "Scalable fonts"
    38             Binding on checked { value: fontDialog.scalableFonts }
    39         }
    40         CheckBox {
    41             id: fontDialogNonScalableFonts
    42             text: "Non scalable fonts"
    43             Binding on checked { value: fontDialog.nonScalableFonts }
    44         }
    45         CheckBox {
    46             id: fontDialogMonospacedFonts
    47             text: "Monospaced fonts"
    48             Binding on checked { value: fontDialog.monospacedFonts }
    49         }
    50         CheckBox {
    51             id: fontDialogProportionalFonts
    52             text: "Proportional fonts"
    53             Binding on checked { value: fontDialog.proportionalFonts }
    54         }
    55 
    56         Text {
    57             text: "Current font:"
    58         }
    59 
    60         Text {
    61             id: fontLabel
    62             color: palette.windowText
    63             text: "<b>" + fontDialog.font.family + " - " + fontDialog.font.pointSize + "</b>"
    64             MouseArea {
    65                 anchors.fill: parent
    66                 onClicked: fontDialog.open()
    67             }
    68         }
    69 
    70         Text {
    71             id: textFontDemoLowerCase
    72             text: "abcdefghijklmnopqrstyvwxyz"
    73             font: fontDialog.font
    74         }
    75 
    76         Text {
    77             id: textFontDemoUpperCase
    78             text: "ABCDEFGHIJKLMNOPQRSTYVWXYZ"
    79             font: fontDialog.font
    80         }
    81 
    82         Text {
    83             id: textFontDemoDigits
    84             text: "0123456789"
    85             font: fontDialog.font
    86         }
    87 
    88 
    89         Button {
    90             text: qsTr("Select Font")
    91             onClicked: fontDialog.open()
    92         }
    93 
    94 
    95     }
    96 }