您当前的位置: 首页 > 

令狐掌门

暂无认证

  • 5浏览

    0关注

    513博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

QML入门教程(7):复选框CheckBox

令狐掌门 发布时间:2020-05-04 00:19:07 ,浏览量:5

QML的复选框是CheckBox,使用代码如下:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    ColumnLayout {
          x:20
          y:20

          CheckBox {
              id:ch1
              checked: true
              text: qsTr("First")
          }
          CheckBox {
              id:ch2
              text: qsTr("Second")
          }
          CheckBox {
              id:ch3
              checked: true
              text: qsTr("Third")
          }

          Button{
              text: "获取CheckBox状态"
              onClicked: {
                  console.log(ch1.checked)
                  console.log(ch2.checked)
                  console.log(ch3.checked)
              }
          }
      }
}

运行界面

关注
打赏
1652240117
查看更多评论
立即登录/注册

微信扫码登录

0.4149s