查看完整版本: [-- GridView位置怎么样设定 --]

QTCN开发网 -> Qt QML开发 -> GridView位置怎么样设定 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

xuekew 2017-09-25 14:35

GridView位置怎么样设定

如题,下面是我的代码
  1. import QtQuick 2.1
    import QtQuick.Controls 1.1
    import QtQuick.Controls.Styles 1.1
    import QtQuick.Layouts 1.0
    //
    Item {
        id:homeRoot;
        anchors.fill:parent;
        Rectangle{
            id:top_Rectangle;
            width:mainRoot.width;
            height:35*dpi;
            color:"red";
            Image{
                id:navi_qrcode;
                width:25*dpi;
                height:25*dpi;
                anchors.top:parent.top;
                anchors.topMargin:5*dpi;
                anchors.left:parent.left;
                anchors.leftMargin:10*dpi;
                source: "qrc:/new/prefix1/icon_navi_qrcode_new.png";
                MouseArea{
                    anchors.fill:parent;
                    focus: true;
                    onClicked:{
                        //扫一扫被点击
                    }
                }
            }
            Rectangle{
                id:search;
                width:(parent.width/6)*4;
                height:(parent.height/3)*2;
                anchors.left:navi_qrcode.right;
                anchors.leftMargin: 5*dpi;
                anchors.top:parent.top;
                anchors.topMargin:(parent.height/3)*0.5;
                color:"#eef1f4";
                radius:10*dpi;
                Image{
                    id:top_search;
                    width:12*dpi;
                    height:12*dpi;
                    anchors.top:parent.top;
                    anchors.topMargin:6*dpi;
                    anchors.left:parent.left;
                    anchors.leftMargin:5*dpi;
                    source:"qrc:/new/prefix1/icon_navigation_search.png";
                }
                Text{
                    text:"请输入搜索内容";
                    anchors.left:top_search.right;
                    anchors.leftMargin:8*dpi;
                    anchors.top:parent.top;
                    anchors.topMargin:2*dpi;
                    font.pixelSize: 14*dpi;
                    color:"#7f7f80";
                }
                Component.onCompleted: {
                    console.log(height);
                }
            }
            Rectangle{
                width:(parent.width/6)*2;
                height:parent.height;
                anchors.left:search.right;
                color:"red";
                Image{
                    source: "qrc:/new/prefix1/icon_navi_im_new.png";
                    anchors.left:parent.left;
                     anchors.leftMargin: parent.width/10;
                     anchors.top:parent.top;
                    anchors.topMargin:5*dpi;
                    width:navi_qrcode.width;
                    height:navi_qrcode.height;
                }
            }
        }
        ListModel{
            id:lsitmode;
            ListElement{
                title:"WIFI"
            }
            ListElement{
                title:"签证"
            }
            ListElement{
                title:"自由行"
            }
            ListElement{
                title:"自由行"
            }
            ListElement{
                title:"自由行"
            }
            ListElement{
                title:"自由行"
            }ListElement{
                title:"自由行"
            }
        }

            Component{
                id:warper;
                    RowLayout{
                    Text{
                        text:title;
                        anchors.fill:parent;
                        anchors.top:parent.bottom;
                    }
                }
        }

        GridView {
            width: 180; cellHeight: 10
            anchors.fill: parent
            model: lsitmode;
            delegate: warper
            focus: true
        }


    }



自强不吸 2017-09-26 10:44
给他加个父item  然后设置父item的位置


查看完整版本: [-- GridView位置怎么样设定 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled