Quick QML信号与槽示例
发布日期:2021-05-13 21:00:32 浏览次数:19 分类:精选文章

本文共 2129 字,大约阅读时间需要 7 分钟。

���������������������������������������������������

���������������QtQuick���.qml������������������������������������������������������������������������������������������������������������������������

������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

������������������

������������������������������������������

  • ������������������������win���������������������������������������������

  • ������������������������txt������������������������������������������

������������������������������������������������������

  • ���������������������������������������������

  • ������������������������������������������x���������������������������

  • ������������������������������������������y���������������������������

  • ������������������

    import QtQuick 2.4

    import QtQuick.Window 2.2

    import QtQuick.Controls 1.3

    Rectangle {

    id: win
    width: 300
    height: 200
    color: "red"
    Text {
    id: txt
    text: "Center Text"
    font.pointSize: 20
    }
    // ������������
    onWidthChanged: {
    txt.x = (win.width - txt.width) / 2;
    }
    onHeightChanged: {
    txt.y = (win.height - txt.height) / 2;
    }

    }

    ������������������

    ���������������������������������������������������������������������

  • ������anchors.centerIn���������
  • onWidthChanged {

    txt.anchors.centerIn: parent

    }

    onHeightChanged {

    txt.anchors.centerIn: parent

    }

    1. ������anchors���������������
    2. onWidthChanged {

      txt.anchors.horizontalCenter = (win.width - txt.width) / 2;

      }

      onHeightChanged {

      txt.anchors.verticalCenter = (win.height - txt.height) / 2;

      }

      ������������������������������������������������������������������������������������������������������

      ���������������������

      ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

      ������������������������������������������QtQuick������������������������������������������������������������������

    上一篇:QML按钮三态实现
    下一篇:Quick QML Rectangle

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2025年04月18日 20时47分14秒