日期:2014-05-16  浏览次数:20800 次

请教大侠!
请教大侠:
下面括号中的数字什么意思阿,QGridLayout文档里面没有发现与下面函数对应的构造函数
mainGrid   =   new   QGridLayout(this,   2,   1,   5,   5);

------解决方案--------------------
QGridLayout ( QWidget * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 )
QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )
QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )
there are three construct function in this.
but,you have used the first.
the api said like this:
Constructs a new QGridLayout with nRows rows, nCols columns and parent widget, parent. parent may not be 0. The grid layout is called name.
margin is the number of pixels between the edge of the widget and its managed children. space is the default number of pixels between cells. If space is -1, the value of margin is used.


------解决方案--------------------
没有用到并不代表可以不传参数进去。

从编译器的角度讲mainGrid = new QGridLayout(this, 2, 1, 5, 5);应该还是匹配构造函数
QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )

nRows = 2
nCols = 1
spacing = 5
name = 5