im trying to create a matrix grid that changes its size when an option in the combobox is selected, i dont know how to call the function that creates the grid everytime i change the value of the combo box...
void MatrixOP::createGridMatrixSize()
{
setMatrixSize
=new QGroupBox(tr
("Select Size"));
chooseSize
->addItems
(QStringList()<<
"0"<<
"1"<<
"2"<<
"3"<<
"4"<<
"5"<<
"6"<<
"7"<<
"8"<<
"9"<<
"10");
chooseSize->setCurrentIndex(1);
layout->addWidget(sizeLabel, 0,0);
layout->addWidget(chooseSize, 0,1);
setMatrixSize->setLayout(layout);
}
void MatrixOP::createGridMatrixValues()
{
int gridSize=chooseSize->currentIndex();
setMatrixValues
= new QGroupBox (tr
("Input Values"));
for(int j=1; j<=gridSize;j++){
for (int i=1; i<=gridSize;i++){
layout->addWidget(matrixValues[i], j, i+1);
}
}
setMatrixValues->setLayout(layout);
}
void MatrixOP::createGridMatrixSize()
{
setMatrixSize=new QGroupBox(tr("Select Size"));
QGridLayout *layout =new QGridLayout;
QLabel *sizeLabel = new QLabel(tr("Size"));
QComboBox *chooseSize = new QComboBox;
chooseSize->addItems(QStringList()<<"0"<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8"<<"9"<<"10");
chooseSize->setCurrentIndex(1);
layout->addWidget(sizeLabel, 0,0);
layout->addWidget(chooseSize, 0,1);
setMatrixSize->setLayout(layout);
}
void MatrixOP::createGridMatrixValues()
{
int gridSize=chooseSize->currentIndex();
setMatrixValues = new QGroupBox (tr("Input Values"));
QGridLayout *layout = new QGridLayout;
for(int j=1; j<=gridSize;j++){
for (int i=1; i<=gridSize;i++){
matrixValues[i]=new QLineEdit;
layout->addWidget(matrixValues[i], j, i+1);
}
}
setMatrixValues->setLayout(layout);
}
To copy to clipboard, switch view to plain text mode
i believe it can be done with SIGNALS and SLOTS but i cant figure out the way to refresh the mainwindow to "redraw" the grid....any help?thx
Bookmarks