QML Performance

1) Limit JavaScript
javascript

  a) inline JavaScript:  內聯的JavaScript方法;
  1. 將js方法放置在Element內部; 2. 嘗試將語句寫在一行內; e.g.
html

Item {  
     function factorial(a) {  
        ...  
     }  
     MouseArea {  
         onClicked: console.log(factorial(10)) //try to avoid the {brace};  
     }  
 }

  b) 對於複雜的邏輯業務, 用C++代替JavaScript實現;java


2) Clipping: 只有在必須的時候使用 Item.clip, 在painting的時候它會影響程序的效率; 緩存


3) Image spa

  a) 使用 Image.sourceSize 屬性來將圖片擴大以顯示大圖片, 這樣能夠省下大圖片所佔的空間;  orm

  b) 只有在必須的時候使用 Image.smooth.  htm

  c) 不要使用一大堆複雜的Element組合來畫圖, 提供一張IMAGE資源就能夠簡單有效地顯示靜態圖像; blog


4) Anchors vs. Binding 圖片

使用anchors比起把x,y位置根據互相關係固定起來的方式要有效率, 並且在左右互換或實現鏡像的時候更合適; ip


5) Opaque Items: 若是一個Item被一個不透明的item整個遮蓋住了, 把這個item的opacity設爲0;


6) View delegatescacheBuffer 設定必定的值(根據具體狀況選擇大小), 把View裏面的Item緩存起來;


 

由系統環境決定:

-Use showFullScreen() 全屏顯示

-Use a different graphics system 更換一個圖形系統;


Refer to: http://doc.qt.digia.com/4.7/qdeclarativeperformance.html  & http://cdumez.blogspot.com/2010/12/ways-to-improve-qml-performance.html

相關文章
相關標籤/搜索