在使用gridlayout時,同一種設定常常有不同的寫法,現總結如下:
1.gridlayout設定:
gridlayout layout = new gridlayout();
// 設定容器的列數
layout.numcolumns = 4;
// 設定容器上的元件是否等距分開
layout.makecolumnsequalwidth = false;
等價寫法:
gridlayout layout = new gridlayout(4, false);
2.griddata.grabexcesshorizontalspace、griddata.grabexcessverticalspace
①griddata.grabexcesshorizontalspace
griddata griddata = new griddata();
// 當容器大小變化時,元件所在列空間橫向隨容器的變化而變化
griddata.grabexcesshorizontalspace = true;
等價寫法:
griddata griddata = new griddata(griddata.grab_horizontal);
②griddata.grabexcessverticalspace
griddata griddata = new griddata();
// 當容器大小變化時,元件所在行空間縱向隨容器的變化而變化
griddata.grabexcessverticalspace = true;
等價寫法:
griddata griddata = new griddata(griddata.grab_vertical);
3.griddata.fill_horizontal、griddata.fill_vertical、griddata.fill_both
① griddata.fill_horizontal:
griddata griddata = new griddata();
// 橫向對齊方式
griddata.horizontalalignment = griddata.fill;
griddata.grabexcesshorizontalspace = true;
等價寫法:
griddata griddata = new griddata(griddata.fill_horizontal);
②griddata.fill_vertical
griddata griddata = new griddata();
// 縱向對齊方式
griddata.verticalalignment = griddata.fill;
griddata.grabexcessverticalspace = true;
等價寫法:
griddata griddata = new griddata(griddata.fill_vertical);
③griddata.fill_both
griddata griddata = new griddata(griddata.fill_horizontal | griddata.fill_vertical);
等價寫法:
griddata griddata = new griddata(griddata.fill_both);
QML中的GridLayout布局
gridlayout是乙個網格布局,真的是無需多說。來看乙個示例 import qtquick 2.3 import qtquick.window 2.2 import qtquick.controls 1.4 import qtquick.layouts 1.1 window button but...
gridlayout在kv中的引用
from kivy.uix.gridlayout import gridlayout class gridlayoutwidget gridlayout def init self,kwargs super init kwargs class defbuild self return gridlay...
常用的幾種模組
usr bin env python coding utf 8 tmie模組 在python中通常有3種表示時間的方法 時間戳 時間戳表示的是從1970年1月1日00 00 00開始按秒計算的偏移量 格式化的時間字串 結構化時間 struct time 結構化時間元組共有9個元素共九個元素 年,月,...