Rendu des composants dans Qt Quick 2.x
par
, 13/06/2015 à 19h00 (1829 Affichages)
Vous avez peut-être remarqué que naturellement le rendu entre un composant Text (Qt Quick 2.x) et son homologue dans Qt Quick Controls 1.x, c'est à dire le Label est différent.
En ce qui me concerne je préfère celui du Label. Travaillant actuellement sur un projet où je ne souhaite pas utiliser les Qt Quick Controls, j'ai décidé de prendre le taureau (enfin ... le bébé taureau) par les cornes et trouver d'où venait cette différence.
Voici un petit bout de code qui met en évidence les différences et la manière d'arriver à mes fins :
Code qml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 import QtQuick 2.4 import QtQuick.Controls 1.3 Rectangle { width: 800 height: 300 property string testText: "Ceci est un TEST de Text" property string testLabel: "Ceci est un TEST de Label" Text{ id: txt anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top text: testText } Label{ id: label anchors.horizontalCenter: parent.horizontalCenter anchors.top: txt.bottom text: testLabel } Rectangle{ id: rect anchors.horizontalCenter: parent.horizontalCenter anchors.top: label.bottom height: 30; width: 30 } Row{ id: row anchors.horizontalCenter: parent.horizontalCenter anchors.top: rect.bottom spacing: 100 Text{ text: "Détail composant Text : Style : " +txt.style +" Font : " + txt.font.family+" Color : "+txt.color+" Gras : "+txt.font.bold+" Pixel : "+txt.font.pixelSize+" Size : "+txt.font.pointSize+" Render : "+txt.renderType+" Format : "+txt.textFormat+" Antialising : "+txt.antialiasing } Label{ text: "Détail composant Label : Style : " +label.style +" Font : " + label.font.family+" Color : "+label.color+" Gras : "+label.font.bold+" Pixel : "+label.font.pixelSize+" Size : "+label.font.pointSize+" Render : "+label.renderType+" Format : "+label.textFormat+" Antialising : "+label.antialiasing } } Rectangle{ id: rect1 anchors.horizontalCenter: parent.horizontalCenter anchors.top: row.bottom height: 30; width: 30 } Text{ id: txt1 anchors.horizontalCenter: parent.horizontalCenter anchors.top: rect1.bottom text: testText + " modifié" renderType: Text.NativeRendering } Label{ id: label1 anchors.horizontalCenter: parent.horizontalCenter anchors.top: txt1.bottom text: testLabel } }
Rien d'exceptionnel mais comme je voulais vraiment régler ce problème j'en profite pour mettre ceci ici
Bon WE à tous.
J