Qt文档阅读笔记-GridLayout QML Type解析与实例
生活随笔
收集整理的這篇文章主要介紹了
Qt文档阅读笔记-GridLayout QML Type解析与实例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
?
?
基本概念
代碼與實例
?
基本概念
如果QGridLaout大小被調整,所有item的布局都將會重新排列。和widget的QGridLayout一樣。如果想要一行或一列的布局可以使用RowLayout和ColumnLayout。
如果指定了columns這個屬性,他會限制列的大小。
運行截圖如下:
rows為垂直限制
?
代碼與實例
程序運行截圖如下:
qml代碼如下:
import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Layouts 1.1Window {visible: truewidth: mGridLayoutId.implicitWidthheight: mGridLayoutId.implicitHeighttitle: qsTr("Hello World")property int intValue: 100GridLayout {id: mGridLayoutIdanchors.fill: parentcolumns: 3layoutDirection: Qt.RightToLeftRectangle{id: topLeftRectIdwidth: intValueheight: intValueLayout.fillWidth: trueLayout.fillHeight: truecolor: "green"}Rectangle{width: intValueheight: intValueLayout.fillWidth: trueLayout.fillHeight: truecolor: "red"}Rectangle{width: intValueheight: intValueLayout.fillWidth: trueLayout.fillHeight: truecolor: "blue"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "yellow"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "pink"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "magenta"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "yellowgreen"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "dodgerblue"}Rectangle{width: intValueheight: intValueLayout.fillHeight: trueLayout.fillWidth: truecolor: "black"}} }?
總結
以上是生活随笔為你收集整理的Qt文档阅读笔记-GridLayout QML Type解析与实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS笔记-前端实现验证码功能
- 下一篇: Qt文档阅读笔记-Rotations E