SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
超酷炫科幻 UI
QML 入門
Fred Chien
錢逢祥
超酷炫科幻 UI
你會想到什麼?
QML
Qt Modeling Language
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 200;
height: 200;
}
長相如下:
http://qt.io/
5.0, 5.1, 5.2, 5.3 or 5.4+
Qt 5
Windows, Linux, Mac OS
Cross-platform
Android, iOS...
Cross-platform
就想到 C++
很多人看到 Qt
Don't Worry
別擔心
我們今天絕對不會用到
我們只會提到
QML
Qt Modeling Language
There are serval way to play QML
你有幾種方式可以跑 QML
Linux 使用者唯一的方法
直接裝 Qt
Windows & Mac 使用者
使用 OwaViewer
從例子來看
基本用法
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
第一個例子
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
第一個例子
一個 QML 檔案中
最基本的模組
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
第一個例子
控制相關模組
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
第一個例子
元件類型 {
屬性: 參數
...
}
import QtQuick 2.3
import QtQuick.Controls 1.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
第一個例子
視窗可顯示
視窗寬度
視窗高度
自己打造的視窗!
現在你有一個視窗了!
加入一個元件到視窗中
加入一張圖片吧
Image {
x: 50;
y: 80;
width: 200;
height: 200;
source: 'example.jpg'
}
圖片元件的基本使用
x 軸座標位置
y 軸座標位置
圖片寬度
圖片高度
圖片檔案位置
import QtQuick 2.3
import QtQuick.Controls 2.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
}
加入元件到視窗中
import QtQuick 2.3
import QtQuick.Controls 2.3
ApplicationWindow {
visible: true;
width: 800;
height: 600;
Image { ... }
}
加入元件到視窗中
Image {
x: 50;
y: 80;
width: 200;
height: 200;
source: 'example.jpg'
}
Text 元件
加入一段文字吧
Text {
x: 50;
y: 80;
font.pointSize: 20;
text: 'QML Workshop';
color: '#ffffff';
}
文字元件的基本使用
字體大小
字串內容
字體顏色
font.bold: true;
font.family: 'Arial';
font.italic: true;
font.underline: true;
font.strikeout: true;
lineHeight: true;
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
文字元件的更多常用屬性
Rectangle 元件
矩形色塊
Rectangle {
x: 50;
y: 80;
width: 200;
height: 200;
radius: 5;
color: 'red';
}
矩形元件的基本使用
gradient: Gradient {
GradientStop { position: 0.0; color: '#000000' }
GradientStop { position: 1.0; color: '#ffffff' }
}
矩形元件的漸層填色屬性
特異功能由此開始
元件的基本屬性
visible: true;
opacity: 0.5;
rotation: 45;
scale: 0.5;
常用基本屬性
是否可見
透明度
旋轉角度
尺寸大小
Layout
排版
anchors.left
anchors.right
anchors.top
anchors.bottom
anchors.centerIn
Anchors 常用屬性
Animation
動畫
NumberAnimation {
target: box;
running: true;
property: 'opacity';
from: 0;
to: 1;
duration: 1000;
easing.type: Easing.Linear;
}
動畫元件範例
對特定元件套用動畫
對特定屬性做變化
啟用動畫
動畫持續一秒
線性加速
數值起始點
數值終止點
ColorAnimation {
target: box;
running: true;
property: 'color';
to: 'yellow';
duration: 1000;
easing.type: Easing.Linear;
}
顏色動畫元件
對特定元件套用動畫
對特定屬性做變化
啟用動畫
動畫持續一秒
線性加速
數值終止點
SequentialAnimation {
running: true;
loops: 3;
}
有序動畫元件
循環次數
若想無限循環,可設 loops 為 Animation.Infinite
SequentialAnimation {
running: true;
NumberAnimation { ... }
NumberAnimation { ... }
NumberAnimation { ... }
NumberAnimation { ... }
}
有序動畫元件
完成後才跑下一個動畫
ParallelAnimation {
running: true;
NumberAnimation { ... }
NumberAnimation { ... }
NumberAnimation { ... }
NumberAnimation { ... }
}
平行動畫元件
全部動畫同時一起跑
更多練習
More Examples

Más contenido relacionado

La actualidad más candente

Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheusBrice Fernandes
 
Kubernetes - Security Journey
Kubernetes - Security JourneyKubernetes - Security Journey
Kubernetes - Security JourneyJerry Jalava
 
Clean architectures with fast api pycones
Clean architectures with fast api   pyconesClean architectures with fast api   pycones
Clean architectures with fast api pyconesAlvaro Del Castillo
 
Why Katalon Studio?
Why Katalon Studio?Why Katalon Studio?
Why Katalon Studio?Knoldus Inc.
 
Introduction to XAML and WPF
Introduction to XAML and WPFIntroduction to XAML and WPF
Introduction to XAML and WPFDoncho Minkov
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio
 
Exploiting IAM in the google cloud platform - dani_goland_mohsan_farid
Exploiting IAM in the google cloud platform - dani_goland_mohsan_faridExploiting IAM in the google cloud platform - dani_goland_mohsan_farid
Exploiting IAM in the google cloud platform - dani_goland_mohsan_faridCloudVillage
 
Qt Memory Management & Signal and Slots
Qt Memory Management & Signal and SlotsQt Memory Management & Signal and Slots
Qt Memory Management & Signal and SlotsJussi Pohjolainen
 
On the Application of AI for Failure Management: Problems, Solutions and Algo...
On the Application of AI for Failure Management: Problems, Solutions and Algo...On the Application of AI for Failure Management: Problems, Solutions and Algo...
On the Application of AI for Failure Management: Problems, Solutions and Algo...Jorge Cardoso
 
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021Florian Roth
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
Katalon Studio - A Codeless Automation Tool.pdf
Katalon Studio - A Codeless Automation Tool.pdfKatalon Studio - A Codeless Automation Tool.pdf
Katalon Studio - A Codeless Automation Tool.pdfKnoldus Inc.
 
Selenium
SeleniumSelenium
Seleniumeduquer
 
Istio service mesh introduction
Istio service mesh introductionIstio service mesh introduction
Istio service mesh introductionKyohei Mizumoto
 
IBM JVM GC_Wh apm
IBM JVM GC_Wh apmIBM JVM GC_Wh apm
IBM JVM GC_Wh apm엑셈
 

La actualidad más candente (20)

Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheus
 
Kubernetes - Security Journey
Kubernetes - Security JourneyKubernetes - Security Journey
Kubernetes - Security Journey
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Clean architectures with fast api pycones
Clean architectures with fast api   pyconesClean architectures with fast api   pycones
Clean architectures with fast api pycones
 
Why Katalon Studio?
Why Katalon Studio?Why Katalon Studio?
Why Katalon Studio?
 
Introduction to XAML and WPF
Introduction to XAML and WPFIntroduction to XAML and WPF
Introduction to XAML and WPF
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI Overview
 
Exploiting IAM in the google cloud platform - dani_goland_mohsan_farid
Exploiting IAM in the google cloud platform - dani_goland_mohsan_faridExploiting IAM in the google cloud platform - dani_goland_mohsan_farid
Exploiting IAM in the google cloud platform - dani_goland_mohsan_farid
 
Wpf Introduction
Wpf IntroductionWpf Introduction
Wpf Introduction
 
Qt Memory Management & Signal and Slots
Qt Memory Management & Signal and SlotsQt Memory Management & Signal and Slots
Qt Memory Management & Signal and Slots
 
On the Application of AI for Failure Management: Problems, Solutions and Algo...
On the Application of AI for Failure Management: Problems, Solutions and Algo...On the Application of AI for Failure Management: Problems, Solutions and Algo...
On the Application of AI for Failure Management: Problems, Solutions and Algo...
 
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021
Sigma Hall of Fame - EU ATT&CK User Workshop, October 2021
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Katalon Studio - A Codeless Automation Tool.pdf
Katalon Studio - A Codeless Automation Tool.pdfKatalon Studio - A Codeless Automation Tool.pdf
Katalon Studio - A Codeless Automation Tool.pdf
 
Selenium
SeleniumSelenium
Selenium
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Istio service mesh introduction
Istio service mesh introductionIstio service mesh introduction
Istio service mesh introduction
 
IBM JVM GC_Wh apm
IBM JVM GC_Wh apmIBM JVM GC_Wh apm
IBM JVM GC_Wh apm
 

Similar a 超酷炫科幻 UI:QML 入門

C++ gui qt
C++ gui qtC++ gui qt
C++ gui qtbiehege
 
使用Qt+和open gl®+创建跨平台可视化ui
使用Qt+和open gl®+创建跨平台可视化ui使用Qt+和open gl®+创建跨平台可视化ui
使用Qt+和open gl®+创建跨平台可视化uilsdsjy
 
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT introigdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT introigdshare
 
用最潮的 Java script 盡情開發 kde qt 程式
用最潮的 Java script 盡情開發 kde qt 程式用最潮的 Java script 盡情開發 kde qt 程式
用最潮的 Java script 盡情開發 kde qt 程式Fred Chien
 
Python&GUI
Python&GUIPython&GUI
Python&GUILeo Zhou
 
QML + Arduino & Leap Motion
QML + Arduino & Leap MotionQML + Arduino & Leap Motion
QML + Arduino & Leap Motiondiro fan
 
Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture lusecheng
 
IoT開發平台NodeMCU
IoT開發平台NodeMCUIoT開發平台NodeMCU
IoT開發平台NodeMCU承翰 蔡
 
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例TIM WANG
 
程式人雜誌 -- 2013年2月號
程式人雜誌 -- 2013年2月號程式人雜誌 -- 2013年2月號
程式人雜誌 -- 2013年2月號鍾誠 陳鍾誠
 
QML 與 C++ 的美麗邂逅
QML 與 C++ 的美麗邂逅QML 與 C++ 的美麗邂逅
QML 與 C++ 的美麗邂逅Jack Yang
 
Node.js 進攻桌面開發
Node.js 進攻桌面開發Node.js 進攻桌面開發
Node.js 進攻桌面開發Fred Chien
 
Qt 入門就上手 !!
Qt 入門就上手 !!Qt 入門就上手 !!
Qt 入門就上手 !!輝亮 游
 
[NTU CSIE] Intro to Windows lab
[NTU CSIE] Intro to Windows lab[NTU CSIE] Intro to Windows lab
[NTU CSIE] Intro to Windows labMing-Yuan Jian
 
Linux运维趋势 第0期 运维自动化
Linux运维趋势 第0期 运维自动化Linux运维趋势 第0期 运维自动化
Linux运维趋势 第0期 运维自动化51CTO
 

Similar a 超酷炫科幻 UI:QML 入門 (20)

C++ gui qt
C++ gui qtC++ gui qt
C++ gui qt
 
Qt gui编程
Qt gui编程Qt gui编程
Qt gui编程
 
LLVM introduction
LLVM introductionLLVM introduction
LLVM introduction
 
使用Qt+和open gl®+创建跨平台可视化ui
使用Qt+和open gl®+创建跨平台可视化ui使用Qt+和open gl®+创建跨平台可视化ui
使用Qt+和open gl®+创建跨平台可视化ui
 
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT introigdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT intro
 
用最潮的 Java script 盡情開發 kde qt 程式
用最潮的 Java script 盡情開發 kde qt 程式用最潮的 Java script 盡情開發 kde qt 程式
用最潮的 Java script 盡情開發 kde qt 程式
 
全新的Qt5
全新的Qt5全新的Qt5
全新的Qt5
 
Python&GUI
Python&GUIPython&GUI
Python&GUI
 
QML + Arduino & Leap Motion
QML + Arduino & Leap MotionQML + Arduino & Leap Motion
QML + Arduino & Leap Motion
 
Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture Coscup2011: porting android to brand-new cpu architecture
Coscup2011: porting android to brand-new cpu architecture
 
IoT開發平台NodeMCU
IoT開發平台NodeMCUIoT開發平台NodeMCU
IoT開發平台NodeMCU
 
Inside VCL
Inside VCLInside VCL
Inside VCL
 
Java - TA課 - 開發環境
Java - TA課 - 開發環境Java - TA課 - 開發環境
Java - TA課 - 開發環境
 
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
 
程式人雜誌 -- 2013年2月號
程式人雜誌 -- 2013年2月號程式人雜誌 -- 2013年2月號
程式人雜誌 -- 2013年2月號
 
QML 與 C++ 的美麗邂逅
QML 與 C++ 的美麗邂逅QML 與 C++ 的美麗邂逅
QML 與 C++ 的美麗邂逅
 
Node.js 進攻桌面開發
Node.js 進攻桌面開發Node.js 進攻桌面開發
Node.js 進攻桌面開發
 
Qt 入門就上手 !!
Qt 入門就上手 !!Qt 入門就上手 !!
Qt 入門就上手 !!
 
[NTU CSIE] Intro to Windows lab
[NTU CSIE] Intro to Windows lab[NTU CSIE] Intro to Windows lab
[NTU CSIE] Intro to Windows lab
 
Linux运维趋势 第0期 运维自动化
Linux运维趋势 第0期 运维自动化Linux运维趋势 第0期 运维自动化
Linux运维趋势 第0期 运维自动化
 

Más de Fred Chien

MakerBoard: MT7688 Emulator
MakerBoard: MT7688 EmulatorMakerBoard: MT7688 Emulator
MakerBoard: MT7688 EmulatorFred Chien
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Fred Chien
 
Koa 正在等一個人
Koa 正在等一個人Koa 正在等一個人
Koa 正在等一個人Fred Chien
 
Stem OS Proposal
Stem OS ProposalStem OS Proposal
Stem OS ProposalFred Chien
 
Stem is JavaScript OS
Stem is JavaScript OSStem is JavaScript OS
Stem is JavaScript OSFred Chien
 
我編譯故我在:誰說 Node.js 程式不能編成 binary
我編譯故我在:誰說 Node.js 程式不能編成 binary我編譯故我在:誰說 Node.js 程式不能編成 binary
我編譯故我在:誰說 Node.js 程式不能編成 binaryFred Chien
 
Java script 全面逆襲!使用 node.js 打造桌面環境!
Java script 全面逆襲!使用 node.js 打造桌面環境!Java script 全面逆襲!使用 node.js 打造桌面環境!
Java script 全面逆襲!使用 node.js 打造桌面環境!Fred Chien
 
Enjoy Writing Modern Desktop Application in JavaScript
Enjoy Writing Modern Desktop Application in JavaScriptEnjoy Writing Modern Desktop Application in JavaScript
Enjoy Writing Modern Desktop Application in JavaScriptFred Chien
 
軟體人甘苦談
軟體人甘苦談軟體人甘苦談
軟體人甘苦談Fred Chien
 
Non-MVC Web Framework
Non-MVC Web FrameworkNon-MVC Web Framework
Non-MVC Web FrameworkFred Chien
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.jsFred Chien
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 

Más de Fred Chien (15)

MakerBoard: MT7688 Emulator
MakerBoard: MT7688 EmulatorMakerBoard: MT7688 Emulator
MakerBoard: MT7688 Emulator
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險
 
Koa 正在等一個人
Koa 正在等一個人Koa 正在等一個人
Koa 正在等一個人
 
OwaNEXT
OwaNEXTOwaNEXT
OwaNEXT
 
QML + Node.js
QML + Node.jsQML + Node.js
QML + Node.js
 
Stem OS Proposal
Stem OS ProposalStem OS Proposal
Stem OS Proposal
 
Stem is JavaScript OS
Stem is JavaScript OSStem is JavaScript OS
Stem is JavaScript OS
 
我編譯故我在:誰說 Node.js 程式不能編成 binary
我編譯故我在:誰說 Node.js 程式不能編成 binary我編譯故我在:誰說 Node.js 程式不能編成 binary
我編譯故我在:誰說 Node.js 程式不能編成 binary
 
App house
App houseApp house
App house
 
Java script 全面逆襲!使用 node.js 打造桌面環境!
Java script 全面逆襲!使用 node.js 打造桌面環境!Java script 全面逆襲!使用 node.js 打造桌面環境!
Java script 全面逆襲!使用 node.js 打造桌面環境!
 
Enjoy Writing Modern Desktop Application in JavaScript
Enjoy Writing Modern Desktop Application in JavaScriptEnjoy Writing Modern Desktop Application in JavaScript
Enjoy Writing Modern Desktop Application in JavaScript
 
軟體人甘苦談
軟體人甘苦談軟體人甘苦談
軟體人甘苦談
 
Non-MVC Web Framework
Non-MVC Web FrameworkNon-MVC Web Framework
Non-MVC Web Framework
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 

超酷炫科幻 UI:QML 入門