首页 > 其他 > 详细

我的QML

时间:2018-07-26 18:02:24      阅读:212      评论:0      收藏:0      [点我收藏+]

1、键盘加Text

import QtQuick 2.7
import QtGraphicalEffects 1.0
Rectangle{
    width:300;
    height:200;
    color:"#C0C0C0";
    focus:true;
    Keys.enabled:true;
    Keys.onEscapePressed:Qt.quit();
    Keys.onBackPressed:Qt.quit();
    Keys.onPressed:{
        switch(event.key){
        case Qt.Key_0:
        case Qt.Key_1:
        case Qt.Key_2:
        case Qt.Key_3:
        case Qt.Key_4:
        case Qt.Key_5:
        case Qt.Key_6:
        case Qt.Key_7:
        case Qt.Key_8:
        case Qt.Key_9:
            event.accepted=true;
            keyView.text = event.key-Qt.Key_0;
            break;
        }
    }
    Text{
        id:keyView;
        font.bold:true;
        font.pixelSize:24;
        text:"Waiting";
        anchors.centerIn:parent;
        color:"#FF0000";
    }
    Glow{//光影
        anchors.fill:keyView;
        radius:8;
        samples:17;
        color:"white";
        source:keyView;
    }
}

技术分享图片

 2、按钮+信号

import QtQuick 2.7
import QtQuick.Controls 2.2
Rectangle{
    width:300;
    height:200;
    color:"gray";
    Button{
        text:"Quit";
        anchors.centerIn:parent;
        onClicked:Qt.quit();
    }
}

技术分享图片

 

我的QML

原文:https://www.cnblogs.com/judes/p/9372700.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!