久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

QML之可視化元素

 t涂鴉 2012-02-21

1、Item

      所有的QML可視化元素都繼承自Item,。Item沒(méi)有可視化界面,,但是它定義了可視化元素的所有屬性。

   

  1. import Qt 4.7  
  2. Item{  
  3.     width500;height400  
  4.     Image{  
  5.         source: "images/qt.png"  
  6.     }  
  7.     Image {  
  8.         x: 80  
  9.         y: 100  
  10.         source: "images/qt.png"  
  11.     }  
  12.     Image {  
  13.         x: 190  
  14.         width100;height100  
  15.         fillMode: Image.Tile  
  16.         source: "images/qt.png"  
  17.     }  
  18. }  
  19. //記住要為Item指定width和height不然運(yùn)行看不到窗體  

 

    按鍵事件:

  1. Item {  
  2.     width200height100  
  3.     focus: true  
  4.     Keys.onPressed: {  
  5.         console.log(event.key);  
  6.         console.log(Qt.Key_Left);  
  7.         if(event.key == Qt.Key_Left){  
  8.             console.log("move left");//控制臺(tái)打印信息  
  9.             event.accepted = true;  
  10.         }  
  11.     }  
  12.      Keys.onSelectPressed: console.log("Selected");  
  13.      Keys.onDigit0Pressed: console.log("0 Pressed");  
  14. }  
  15. //Keys事件還有很多具體可以查API,,onSelectPressed,,我現(xiàn)在也不知道怎么觸發(fā),希望有朋友知道告訴我,。  

Item以及繼承自它的元素的大多數(shù)屬性,,當(dāng)屬性值變化會(huì)有一個(gè)信號(hào)發(fā)射出去。

 

2,、Rectangle

   

  1. Rectangle {  
  2.     width100  
  3.     height100  
  4.     color"white"  
  5.     border.color"#FF12FF"  
  6.     border.width10  
  7.     radius: 10  
  8.     Rectangle {  
  9.         anchors.fill :parent  
  10.         anchors.margins: 10  
  11.         color"red"  
  12.         clip: true  
  13.         Rectangle {  
  14.             anchors.fill: parent  
  15.             border.width1  
  16.         }  
  17.     }  
  18. }  
  19. //注:color的值不能用16進(jìn)制0x******表示  

 

  1. Rectangle{  
  2.     width400height300  
  3.     Rectangle {  
  4.         width80height80  
  5.         color:  "lightsteelblue"  
  6.         radius: 8  
  7.     }  
  8.     Rectangle {  
  9.         y: 100width80height80  
  10.         gradient: Gradient {  
  11.             GradientStop {position0.0color"lightsteelblue"}  
  12.             GradientStop {position1.0color"blue"}  
  13.         }  
  14.         radius: 8  
  15.     }  
  16.     Rectangle {  
  17.          y: 200width80height80  
  18.          rotation: 90  
  19.          gradient: Gradient {  
  20.              GradientStop { position0.0color"lightsteelblue" }  
  21.              GradientStop { position1.0color"blue" }  
  22.          }  
  23.          radius: 8  
  24.      }  
  25. }  

Gradient顧名思義,,即梯度,也就是我們常說(shuō)的逐變色,。一個(gè)gradient 被兩個(gè)或更多的顏色定義混合形成,。顏色可以從位置0.0到1.0逐漸變化,,如:

  1. Rectangle {  
  2.      width100height100  
  3.      gradient: Gradient {  
  4.          GradientStop { position0.0color"red" }  
  5.          GradientStop { position0.33color"yellow" }  
  6.          GradientStop { position1.0color"green" }  
  7.      }  
  8.  }  

Gradient包含一個(gè)屬性:stops:list<GradientStop>

GradientStop元素僅包含兩個(gè)屬性color:color和position:real

 

3,、AnimatedImage

      此元素是用于播放動(dòng)畫(huà)像gif這樣存儲(chǔ)著幀的文件

      

  1. import Qt 4.7  
  2. Rectangle {  
  3.     width: animation.width; height: animation.height + 8  
  4.     AnimatedImage { id: animation; source: "animation.gif" }  
  5.     Rectangle {  
  6.         property int frames: animation.frameCount  
  7.         width4height8  
  8.         x: (animation.width - width) * animation.currentFrame / frames  
  9.         y: animation.height  
  10.         color"red"  
  11.     }  
  12. }  

 

 

4、TextInput

       做過(guò)界面開(kāi)發(fā)的應(yīng)該都知道這就是個(gè)單行文本框.它有很多豐富的屬性

     

  1. TextInput {  
  2.     id: textInput  
  3.     text: "Hello world!"  
  4.     width200;  
  5.     height20;  
  6.     activeFocusOnPress: false  
  7.     selectionColor: "#00FF00"  
  8.     selectByMouse: true  
  9.     echoMode: TextInput.Password  
  10.     MouseArea {  
  11.         anchors.fill: parent  
  12.         onClicked: {  
  13.             if (!textInput.activeFocus) {  
  14.                 textInput.forceActiveFocus()  
  15.                 textInput.openSoftwareInputPanel();  
  16.             } else {  
  17.                 textInput.focus = false;  
  18.             }  
  19.         }  
  20.         onPressAndHold: textInput.closeSoftwareInputPanel();  
  21.     }  
  22. }   

 

5,、TextEdit

       多行文本框.

6,、Image

      上面已用到過(guò)了,就是普通顯示圖片的元素

7,、Text

       通常就是用作一個(gè)標(biāo)簽,,在界面上顯示信息.

8、BorderImage

      用來(lái)做窗口的邊界,。

     http://www./?p=592 介紹的很詳細(xì),。哈哈。謝謝這個(gè)網(wǎng)站,,我在里面學(xué)了很多qt相關(guān)的知識(shí)

9,、除了上面介紹這些之外QML還提供了三個(gè)驗(yàn)證器,分別是IntValidator,DoubleValidator,RegExpValidator

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買(mǎi)等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多