Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿

import QtQuick 2.2  
import QtQuick.Controls 1.1
    
Column
{
    spacing: 2
    Repeater
    {
        model: ["A","B","C","D","E","F"]
        Rectangle
        {
            width: 100
            height: 20
            radius: 3
            color: "blue"
            Text
            {
                anchors.centerIn: parent
                text: modelData
            }
        }
    }
}
2
import QtQuick 2.2  
import QtQuick.Controls 1.1
    
Column
{
    spacing: 2
    Repeater
    {
        model: 5
        Rectangle
        {
            width: 100
            height: 20
            radius: 3
            color: "blue"
            Text
            {
                anchors.centerIn: parent
                text: modelData
            }
        }
    }
}

posted @ 2015-08-20 13:53 ccsdu2009 阅读(372) | 评论 (0)编辑 收藏
 
import QtQuick 2.2  
import QtQuick.Controls 1.1 
     
Image 
{
    width
: 240
    height: 240
    source: "assets/background.png"
    Image 
    {
        id: ufo
        y: 90
        x: 90
        width: 48
        height: 48
        source: "assets/ufo.png"
    
}
    
    ParallelAnimation
    
{
        id
: ani
        NumberAnimation
        {
            target: ufo
            properties: "width"
            to: 60
            duration: 600
        
}
        NumberAnimation
        
{
            target
: ufo
            properties: "height"
            to: 60
            duration: 600
        
}    
    }
        
    MouseArea 
    
{
        anchors.fill
: parent
        onClicked: 
        {
            ani.restart()
;
        
}
    }         
}
序列动画
import QtQuick 2.2  
import QtQuick.Controls 1.1 
     
Image 
{
    width
: 240
    height: 240
    source: "assets/background.png"
    Image 
    {
        id: ufo
        y: 90
        x: 90
        width: 48
        height: 48
        source: "assets/ufo.png"
    
}
    
    SequentialAnimation
    
{
        id
: ani
        NumberAnimation
        {
            target: ufo
            properties: "width"
            to: 60
            duration: 600
        
}
        NumberAnimation
        
{
            target
: ufo
            properties: "height"
            to: 60
            duration: 600
        
}    
    }
        
    MouseArea 
    
{
        anchors.fill
: parent
        onClicked: 
        {
            ani.restart()
;
        
}
    }         
}

posted @ 2015-08-20 13:41 ccsdu2009 阅读(592) | 评论 (0)编辑 收藏
 
行列布局
    import QtQuick 2.2  
    import QtQuick.Controls 1.1 
     
    Item 
    
{
        id
: root
        Column 
        {
            id: buttons
            anchors.centerIn: parent
            spacing: 6
            MyButton
            {
                width:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            
            Row 
            
{
                id
: rows
                spacing: 12
                MyButton
                {
                    width:64
                    height:48
                
}
                MyButton
                
{
                    width
:64
                    height:48
                
}
                MyButton
                
{
                    width
:64
                    height:48
                
}
            }
        }
    }   

格子布局
    import QtQuick 2.2  
    import QtQuick.Controls 1.1 
     
    Item 
    
{
        id
: root
        Grid
        {
            id: buttons
            rows: 3
            columns: 2
            anchors.centerIn: parent
            spacing: 6
            MyButton
            {
                width:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
            
}
            MyButton
            
{
                width
:64
                height:48
                color: "red"
            
}
        }
    }   

MyButton.qml
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
     
    Rectangle 
    
{ 
        id
: item
        color: "yellow"
        border.color: "blue"
        Text 
        {
            id: text
            anchors.centerIn: parent
            text: "点击我"
        
}
        MouseArea 
        
{
            anchors.fill
: parent
            onClicked: 
            {
                text.text = "我被点击了"
            
}
        }
    }
posted @ 2015-08-20 11:47 ccsdu2009 阅读(367) | 评论 (0)编辑 收藏
 
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
    
    Rectangle 
    
{
        id
: rect1
        x: 12
; y: 12
        width: 176
; height: 96
        gradient: Gradient 
        {
            GradientStop { position: 0.0
; color: '#FF4444' }
            GradientStop 
{ position: 1.0; color: "blue" }
        }
        // 边框颜色
        border.color: "red"
        radius: 8
        
        Text 
        
{
            text
: "The quick brown fox"
            color: "#303030"
            anchors.centerIn: parent
            font.family: "Ubuntu"
            font.pixelSize: 24
        
}    
    }

再上一个
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
    
    Rectangle 
    
{
        id
: rect1
        x: 12
; y: 12
        width: 176
; height: 96
        gradient: Gradient 
        {
            GradientStop { position: 0.0
; color: '#FF4444' }
            GradientStop 
{ position: 1.0; color: "blue" }
        }
        // 边框颜色
        border.color: "red"
        radius: 8
        
        Text 
        
{
            text
: "The quick brown fox"
            color: "#303060"
            anchors.centerIn: parent
            font.family: "Ubuntu"
            font.pixelSize: 24
            elide: Text.ElideMiddle
            style: Text.Sunken
            styleColor: '#FF4444'
            verticalAlignment: Text.AlignTop
        
}    
    }
使用鼠标控制字体的显示
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
    
    Rectangle 
    
{
        id
: rect1
        x: 12
; y: 12
        width: 176
; height: 96
        gradient: Gradient 
        {
            GradientStop { position: 0.0
; color: '#FF4444' }
            GradientStop 
{ position: 1.0; color: "blue" }
        }
        // 边框颜色
        border.color: "red"
        radius: 8
        
        Text 
        
{
            id
: text
            text: "The quick brown fox"
            color: "#303060"
            anchors.centerIn: parent
            font.family: "Ubuntu"
            font.pixelSize: 24
            elide: Text.ElideMiddle
            style: Text.Sunken
            styleColor: '#FF4444'
            verticalAlignment: Text.AlignTop
            visible: true
        
}    
        
        MouseArea 
        
{
            id
: area
            width: parent.width
            height: parent.height
            onClicked: text.visible = !text.visible
        
}        
    }

posted @ 2015-08-20 11:13 ccsdu2009 阅读(3013) | 评论 (0)编辑 收藏
 
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
    
    Text 
    
{
        id
: label
        x: 24
        y: 24
        
        //here
        property int spacePresses: 0
        
        text: "Space pressed: " + spacePresses + " times"
        onTextChanged: console.log("text changed to:", text)

        focus: true
        
        Keys.onSpacePressed: 
        {
            increment()
        
}
        Keys.onEscapePressed: 
        
{
            label.text = ''
        
}
        
        //! 这是一个js函数
        function increment() 
        
{
            spacePresses = spacePresses + 1
        
}
    }
posted @ 2015-08-20 10:51 ccsdu2009 阅读(361) | 评论 (0)编辑 收藏
 
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
    
    Rectangle 
    
{        
        Image
        {
            anchors.fill
: parent
            id: background
            source: "background.png"
        
}
        
        width: 360
        height: 360
        Text 
        
{
            anchors.centerIn
: parent
            text: "你好世界,点击鼠标退出程序"
        
}
        MouseArea 
        
{
            anchors.fill
: parent
            onClicked: 
            {
                Qt.quit()
;
            
}
        }    
    }   
posted @ 2015-08-20 10:33 ccsdu2009 阅读(268) | 评论 (0)编辑 收藏
 
基本代码如下:
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    Image
    
{
        id
: root
        source: "background.png"
    
}
这个是使用给定图形填充背景,
如果使用多个图形嵌套,做法如下:
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    Image
    
{
        id
: root
        source: "background.png"
        
        Image
        {
            id: head
            source: "head.png"
            anchors.centerIn: parent
            anchors.verticalCenterOffset: 20
        
}
    }
当然可以再加上旋转
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    Image
    {
        id: root
        source: "background.png"
        
        Image
        {
            id: head
            width: 48
            height: 48
            source: "head.png"
            anchors.centerIn: parent
            anchors.verticalCenterOffset: 20
            
            MouseArea
            {
                anchors.fill: parent
                onClicked: head.rotation += 9
            }
        }
    }
加上动画可以让旋转更加平滑点,如下:
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    Image
    
{
        id
: root
        source: "background.png"
        
        Image
        {
            id: head
            width: 48
            height: 48
            source: "head.png"
            anchors.centerIn: parent
            anchors.verticalCenterOffset: 20
            
            MouseArea 
            {
                anchors.fill: parent
                onClicked: head.rotation += 90
            
}
            
            Behavior on rotation 
            
{
                NumberAnimation 
                {
                    duration
: 600
                
}
            }
        }
    }
posted @ 2015-08-20 10:24 ccsdu2009 阅读(348) | 评论 (0)编辑 收藏
 
一个Item对应一个场景,提供隐藏或显示场景即可切换,如下:
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    ApplicationWindow  
    
{  
        visible
: true  
        width:  480  
        height: 360  
        title: "Hello World"  
      
        Item  
        {  
            id: scene_1  
            visible: true  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=red>这是第一个场景</color></h1>" 
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_1.visible = false
;
                    scene_2.visible = true;
                    scene_3.visible = false;                     
                
}  
            }  
      
        }  
      
        Item  
        
{  
            id
: scene_2  
            visible: false  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=green>这是第二个场景</color></h1>" 
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_2.visible = false
;  
                    scene_1.visible = false;
                    scene_3.visible = true;                    
                
}  
            }  
        }  
        
        Item  
        
{  
            id
: scene_3  
            visible: false  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=black>这是第三个场景</color></h1>"
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_1.visible = true
                    scene_2.visible = false
;
                    scene_3.visible = false;                      
                
}  
            }  
        }          
    } 
posted @ 2015-08-19 17:54 ccsdu2009 阅读(446) | 评论 (0)编辑 收藏
 
 如下:
            
            sql 
+= "',N'";
            sql 
+= desc1;
            sql 
+= "',N'";
            sql 
+= desc2;
            sql 
+= "',N'";
            sql 
+= desc3;
            sql 
+= "');select @@identity;";
            
            OleDbConnection conn 
= getOleDbConntion();
            OleDbCommand cmd 
= new OleDbCommand(sql, conn);
            conn.Open();

            OleDbDataReader reader 
= cmd.ExecuteReader();

            reader.Read();
            
string index = reader.GetValue(0).ToString();
            conn.Close();
            
return index;
        }

posted @ 2015-07-29 16:29 ccsdu2009 阅读(340) | 评论 (0)编辑 收藏
 
       Date.prototype.format = function(format) {
            
var args = {
                
"M+"this.getMonth() + 1,
                
"d+"this.getDate(),
                
"h+"this.getHours(),
                
"m+"this.getMinutes(),
                
"s+"this.getSeconds(),
                
"q+": Math.floor((this.getMonth() + 3/ 3),  
                
"S"this.getMilliseconds()
            };
            
if (/(y+)/.test(format))
                format 
= format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            
for (var i in args) {
                
var n = args[i];
                
if (new RegExp("(" + i + ")").test(format))
                    format 
= format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
            }
            
return format;
        };
posted @ 2015-07-13 16:48 ccsdu2009 阅读(338) | 评论 (0)编辑 收藏
仅列出标题
共38页: First 6 7 8 9 10 11 12 13 14 Last