• 3188阅读
  • 2回复

[提问]为什么gridlayouts超边界?? [复制链接]

上一主题 下一主题
离线lovexin109
 

只看楼主 倒序阅读 楼主  发表于: 2017-09-12
  1. Window {
  2.     visible: true
  3.     width: 360
  4.     height: 640
  5.     title: qsTr("Hello World")
  6.     GridLayout{
  7.         anchors.left: parent.left
  8.         columns: 9
  9.         rows:16
  10.         columnSpacing: 1
  11.         rowSpacing: 1
  12.         Label {
  13.             text: qsTr("Type  :")
  14.             Layout.column: 0
  15.             Layout.row: 0
  16.             Layout.columnSpan: 1
  17.         }
  18.         ComboBox{
  19.             id:linearchoose
  20.             Layout.row:0
  21.             Layout.column: 1
  22.             Layout.columnSpan: 8
  23.             Layout.fillWidth: true
  24.             textRole :"com_text"
  25.             model: ListModel{
  26.                 ListElement{com_text:"default";min_scale:"0";max_scale:"100"}
  27.                 ListElement{com_text:"s7-200(0~32000)";min_scale:"0";max_scale:"32000"}
  28.             }
  29.             onActivated: {
  30.                 linearchoose.currentIndex=index
  31.                 text_inmin.text=model.get(index).min_scale
  32.                 text_inmax.text=model.get(index).max_scale
  33.             }
  34.         }
  35.         Label {
  36.             text: qsTr("Input :")
  37.             Layout.row: 1
  38.             Layout.column: 0
  39.         }
  40.         TextField {
  41.             id:text_inmin
  42.             placeholderText: "0"
  43.             Layout.row: 1
  44.             Layout.column: 1
  45.             Layout.columnSpan: 3
  46.         }
  47.         TextField {
  48.             id:text_inmax
  49.             placeholderText: "100"
  50.             Layout.row: 1
  51.             Layout.column: 4
  52.             Layout.columnSpan: 3
  53.         }
  54.         Label {
  55.             text: qsTr("Output:")
  56.             Layout.row: 2
  57.             Layout.column: 0
  58.         }
  59.         TextField {
  60.             id:text_outmin
  61.             placeholderText: "0"
  62.             Layout.row: 2
  63.           Layout.column: 1
  64.             Layout.columnSpan: 3
  65.         }
  66.         TextField {
  67.             id:text_outmax
  68.             placeholderText: "100"
  69.             Layout.row: 2
  70.             Layout.column: 4
  71.             Layout.columnSpan: 3
  72.         }
  73.         Button{
  74.             id:changebutton
  75.             Layout.row: 1
  76.             Layout.column: 7
  77.             Layout.rowSpan: 2
  78.             Layout.columnSpan: 2
  79.             Layout.fillHeight: true
  80.             Layout.fillWidth: true
  81.         }
  82. }
  83. }

显示如下图:右侧还没显示全




窗口拉大才显示全


想请教下为什么gridlayouts超出边界

离线never_forget

只看该作者 1楼 发表于: 2017-09-12
你有设置这个布局的大小吗 ?貌似只是设置了左对齐,可以使用 anchors.fill: parent,也可以指定长宽,试试看!
离线lovexin109

只看该作者 2楼 发表于: 2017-09-12
回 never_forget 的帖子
never_forget:你有设置这个布局的大小吗 ?貌似只是设置了左对齐,可以使用 anchors.fill: parent,也可以指定长宽,试试看! (2017-09-12 11:17) 

试过了,anchors.parent,整个布局都会乱,而且中间还不能间隔,不能完全按格子放,想空一格都空不了,很奇怪这种布局,可能是我没理解这个布局
快速回复
限100 字节
 
上一个 下一个