• 2576阅读
  • 1回复

[提问]GridView位置怎么样设定 [复制链接]

上一主题 下一主题
离线xuekew
 

只看楼主 倒序阅读 楼主  发表于: 2017-09-25
如题,下面是我的代码
  1. import QtQuick 2.1
  2. import QtQuick.Controls 1.1
  3. import QtQuick.Controls.Styles 1.1
  4. import QtQuick.Layouts 1.0
  5. //
  6. Item {
  7.     id:homeRoot;
  8.     anchors.fill:parent;
  9.     Rectangle{
  10.         id:top_Rectangle;
  11.         width:mainRoot.width;
  12.         height:35*dpi;
  13.         color:"red";
  14.         Image{
  15.             id:navi_qrcode;
  16.             width:25*dpi;
  17.             height:25*dpi;
  18.             anchors.top:parent.top;
  19.             anchors.topMargin:5*dpi;
  20.             anchors.left:parent.left;
  21.             anchors.leftMargin:10*dpi;
  22.             source: "qrc:/new/prefix1/icon_navi_qrcode_new.png";
  23.             MouseArea{
  24.                 anchors.fill:parent;
  25.                 focus: true;
  26.                 onClicked:{
  27.                     //扫一扫被点击
  28.                 }
  29.             }
  30.         }
  31.         Rectangle{
  32.             id:search;
  33.             width:(parent.width/6)*4;
  34.             height:(parent.height/3)*2;
  35.             anchors.left:navi_qrcode.right;
  36.             anchors.leftMargin: 5*dpi;
  37.             anchors.top:parent.top;
  38.             anchors.topMargin:(parent.height/3)*0.5;
  39.             color:"#eef1f4";
  40.             radius:10*dpi;
  41.             Image{
  42.                 id:top_search;
  43.                 width:12*dpi;
  44.                 height:12*dpi;
  45.                 anchors.top:parent.top;
  46.                 anchors.topMargin:6*dpi;
  47.                 anchors.left:parent.left;
  48.                 anchors.leftMargin:5*dpi;
  49.                 source:"qrc:/new/prefix1/icon_navigation_search.png";
  50.             }
  51.             Text{
  52.                 text:"请输入搜索内容";
  53.                 anchors.left:top_search.right;
  54.                 anchors.leftMargin:8*dpi;
  55.                 anchors.top:parent.top;
  56.                 anchors.topMargin:2*dpi;
  57.                 font.pixelSize: 14*dpi;
  58.                 color:"#7f7f80";
  59.             }
  60.             Component.onCompleted: {
  61.                 console.log(height);
  62.             }
  63.         }
  64.         Rectangle{
  65.             width:(parent.width/6)*2;
  66.             height:parent.height;
  67.             anchors.left:search.right;
  68.             color:"red";
  69.             Image{
  70.                 source: "qrc:/new/prefix1/icon_navi_im_new.png";
  71.                 anchors.left:parent.left;
  72.                  anchors.leftMargin: parent.width/10;
  73.                  anchors.top:parent.top;
  74.                 anchors.topMargin:5*dpi;
  75.                 width:navi_qrcode.width;
  76.                 height:navi_qrcode.height;
  77.             }
  78.         }
  79.     }
  80.     ListModel{
  81.         id:lsitmode;
  82.         ListElement{
  83.             title:"WIFI"
  84.         }
  85.         ListElement{
  86.             title:"签证"
  87.         }
  88.         ListElement{
  89.             title:"自由行"
  90.         }
  91.         ListElement{
  92.             title:"自由行"
  93.         }
  94.         ListElement{
  95.             title:"自由行"
  96.         }
  97.         ListElement{
  98.             title:"自由行"
  99.         }ListElement{
  100.             title:"自由行"
  101.         }
  102.     }
  103.         Component{
  104.             id:warper;
  105.                 RowLayout{
  106.                 Text{
  107.                     text:title;
  108.                     anchors.fill:parent;
  109.                     anchors.top:parent.bottom;
  110.                 }
  111.             }
  112.     }
  113.     GridView {
  114.         width: 180; cellHeight: 10
  115.         anchors.fill: parent
  116.         model: lsitmode;
  117.         delegate: warper
  118.         focus: true
  119.     }
  120. }


离线自强不吸

只看该作者 1楼 发表于: 2017-09-26
给他加个父item  然后设置父item的位置
自强不吸!
快速回复
限100 字节
 
上一个 下一个