我想像这样切片主窗口
我的布局代码如下:
QGridLayout *gLayout = new QGridLayout ();
viewWidget->setStyleSheet("background-color: #333;" );
for ( i = 0; i < m_numOfVideoWidget; i++)
{
QWidget *vWidget = new QWidget(viewWidget);
vWidget->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
videoList.append( vWidget);
}
index = 0;
for ( j = 0; j < 4; j += 2)
{
gLayout->addWidget( videoList[ index++], 0, j, 2, 2);
}
for ( i = 2; i < 4; i++)
for ( j = 0; j < 4; j++)
gLayout-> addWidget( videoList[ index++], i, j);
viewWidget->setLayout(gLayout );
不幸的是,结果远非预期:
但是当我删除下面的句子时:
vWidget->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
结果是我的预期。
为何
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
会影响QGridLayout吗?
谢谢~