วันพุธที่ 17 กรกฎาคม พ.ศ. 2556

Qt 5.0 Programming VIII : Element FontLoader

Standard

          จากโปรเจคแสดงจำนวนไลค์ในแฟนเพจ ที่เห็นใน Raspberry Pi 66 Club ก็เลยมีความคิดที่จะทำบ้างโดยใช้ RaspberryPi + QML และอยากจะทำให้มันแสดงผลตัวเลขออกมาในรูปขอตัวเลขแบบ Character LCD หรือไม่ก็ 7-Segment ซึ่งตอนแรกตั้งใจว่าจะใช้ภาพในการแสดงผล แต่ดูแล้วต้องการจัดการอีกเยอะ ก็เลยลองหา font ที่แสดงผลเป็น Character LCD หรือ 7-Segment ดูก็เจอในเว็ปนี้ http://www.dafont.com จากนั้นก็ใช้ element FontLoader เพื่อโหลด Font เข้ามาใช้ใน QML ครับ




         หลักๆ ของ FontLoader ก็ไม่มีอะไรมากครับ properties source ก็เป็นชื่อของไฟล์ font ที่จะนำมาใช้ และเวลาที่ใช้งานใน Text element ก็แค่ 
font.family: my_font_1.name;



/*
QML FontLoader
Author : MaIII Themd
Website : http://miiniq.blogspot.com
FB : http://www.facebook.com/PiShared
Env : Qt 5.0.2 clang 64 bit OSX 10.8.4
*/
import QtQuick 2.0
Rectangle {
width: 700
height: 300
color : "black";
FontLoader
{
id : my_font_1;
source: "./fonts/EHSMB.TTF"
}
FontLoader
{
id : my_font_2;
source: "./fonts/DS-DIGIT.TTF"
}
Text
{
id : txt_show_1
text : "http://miiniq.blogspot.com"
font.family: my_font_1.name;
font.pixelSize: 40;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: parent.top;
anchors.topMargin: 80;
color : "#00FF00"
}
Text
{
id : txt_show_2
text : "http://miiniq.blogspot.com"
font.family: my_font_2.name;
font.pixelSize: 55;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: txt_show_1.top;
anchors.topMargin: 80;
color : "#FF0000"
}
}







<< Qt 5.0 Programming VII : Animation part II
>> Qt 5.0 Programming IX : Anchor

Related Posts:

  • Qt 5 Programming X : Call C++ Method     สวัสดีครับ มิตรรักแฟนเพลงทุกท่าน ต้อนรับตัวเองในการกลับมาเขียน Blog เกี่ยวกับ Qt QML อีกครั้งหลังจากห่างหายไปนานถึง 2 ป๊ 555+ พอดี… Read More
  • Qt 5.0 Programming IX : Anchor           ปัญหาใหญ่ๆ ของการออกแบบ GUI บนหน้าจอที่มีความละเอียดต่างกันก็คือเรื่องการจัด layout ถ้าเราวางตำแหน่งของ element … Read More
  • Qt 5.0 Programming VII : Animation part II           วันนี้มาบอกเรื่องการใช้งาน Animation หลักๆ ใน QML กันครับโดยแบ่งเป็น 2 ส่วนหลักๆ คือ การกำหนด Animation ให้กับ … Read More
  • Qt 5.0 Programming VI : Element Image and Animation part I           เรื่องการโหลดภาพและการทำ Animation 2D ด้วย QML นั้นง่ายมากๆ แค่ไม่กี่บรรทัดก็สามารถทำสร้าง Animation ที่สวย… Read More
  • Qt 5.0 Programming VIII : Element FontLoader           จากโปรเจคแสดงจำนวนไลค์ในแฟนเพจ ที่เห็นใน Raspberry Pi 66 Club ก็เลยมีความคิดที่จะทำบ้างโดยใช้ Raspbe… Read More

0 ความคิดเห็น:

แสดงความคิดเห็น