首页 > 编程知识 正文

qt界面教程,delphi7入门教程

时间:2023-05-04 21:45:42 阅读:108742 作者:3671

QML的布局方法是anchors,锚。

例如,界面上的四个按钮可以用绝对坐标(x,y )设定他们的位置。

代码是下一个:

importqtquick 2.12 importqtquick.window 2.12 importqtquick.controls 2.5 window { visible : true width 3360320 height 3360480 TL let color : ' gray ' button { id : btn1x :100 y :100 text :100 '按钮1 ' width 3360100 height 336030 background 3360 rectangle 0880 button { id : btn2x :200 y :160文本: '按钮2' width: 100 height: 30 //按钮背景色background : rectangle { color 167/255,1 } } button { id : btn3x :10 y :220 text :100 height :30 /按钮背景色background : resed 255、167/255、1 ) button (id : BTN 4x :100 y :280 text : )按钮4 )4' width: 100 height: 30 //按钮的背景色backgrg

anchors.top : AnchorLine

anchors.bottom : AnchorLine

anchors.left : AnchorLine

anchors.right : AnchorLine

anchors.horizontal center : anchor line

anchors.vertical center : anchor line

anchors.baseline : anchor line

anchors.fill : Item

anchors.centerIn : Item

anchors.margins : real

anchors.topMargin : real

anchors.bottomMargin : real

anchors.leftMargin : real

anchors.rightMargin : real

anchors.horizontalcenteroffset : real

anchors.verticalcenteroffset :自述

anchors.baseline offset :自述

anchors.alignwhencentered : bool

例如,将接口设置为:

anchors需要用控件的id来设计布局。 例如,上面的实现思路指定了第一个控件的位置,其他控件根据该位置进行布局。 BTN-2的上部和BTN-1的上部相对,BTN-2的左侧位于BTN-1的右侧,距离设计为10.btn3、btn4那样

代码如下所示。

importqtquick 2.12 importqtquick.window 2.12 importqtquick.controls 2.5 window { visible : true width 3360320 height 3360480 titllllll color : ' gray ' button { id : btn1 x :10 y 336010 text : '按钮1' width: 100 height: 30 //按钮背景色background 33: button { id : BTN2///x :200//y :160 text 3360 '按钮2'width3360 '设置/按钮的背景色background : rectangle { coloce } 1 ) anchors.left : BTN1. right anchors.left margin 336020 anchors.top : BTN1. top } buton { id 3360 BTN3///x336000 y:220 text: '按钮3' width: 100 height: 30 //按钮背景颜色background : rectangle { color : Qt.rgba (54/54 ) 54/1 ) anchors.top : BTN1. bottom anchors.top margin 336010 anchors.left : BTN1. left } button { id 3360 BTN4//x 33660 y :280文本: '按钮4' width: 100 height: 30 //按钮背景色background : rectangle { color : Qt.rgba (177/100 ) 设置76/) anchors.left : BTN2. left anchors.top : BTN2. bottom anchors.top margin :10 }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。