Два слоя: один верхний, другой нижний. При динамическом добавлении элементов в QGridLayout зависает. Подскажите в чем проблема.
topLayout = new QHBoxLayout;
comboBox = new QComboBox();
label = new QLabel("Z = ");
topLayout->addWidget(comboBox);
topLayout->addWidget(label);
for(int i = 0; i <= col; i++)
{
lineEdit = new QLineEdit("0");
topLayout->addWidget(lineEdit);
}
leftGrid = new QGridLayout();
//lineEdit = NULL;
for(int i = 0; i <= row; row++)
for(int j = 0; j <= col; col++)
{
lineEdit = new QLineEdit("0");
leftGrid->addWidget(lineEdit, i, j);
}
mainLayout = new QVBoxLayout();
mainLayout->addLayout(topLayout);
mainLayout->addLayout(leftGrid);
this->setLayout(mainLayout);
Попробуйте так:
topLayout = new QHBoxLayout();
comboBox = new QComboBox();
label = new QLabel("Z = ");
topLayout->addWidget(comboBox);
topLayout->addWidget(label);
for (int i = 0; i <= col; i++)
{
lineEdit = new QLineEdit("0");
topLayout->addWidget(lineEdit);
}
leftGrid = new QGridLayout();
for (int i = 0; i <= row; i++)
{
for (int j = 0; j <= col; j++)
{
lineEdit = new QLineEdit("0");
leftGrid->addWidget(lineEdit, i, j);
}
}
mainLayout = new QVBoxLayout();
mainLayout->addLayout(topLayout);
mainLayout->addLayout(leftGrid);
setLayout(mainLayout);
Сборка персонального компьютера от Artline: умный выбор для современных пользователей