At the moment I have a create Slot that is called when a button is pressed. The Slot function needs to get all the data from the ComboBoxes in the QGridLayout above it. In the items above not all them have QComboBoxes. Some of them are QLineEdit and others are QLabel. My QgridLayout is called ui.testgridLayout.
for (int i = 0; i < ui.testgridLayout->rowCount(); i++)
{
for (int j = 0; j < ui.testgridLayout->columnCount(); j++)
{
QLayoutItem *item= ui.testgridLayout->itemAtPosition(i, j);
if (item) {
if (strcmp(item->widget()->metaObject()->className(), "QComboBox")==0) {
QString objName= item->widget()->objectName();
QComboBox* cb =ui.testgridLayout->findChild<QComboBox*>(objName);
string text = cb->currentText().toLocal8Bit().constData();
}
}
}
}
At the moment this returns Unhandled exception at 0x00007FFB107DCC8A (Qt5Widgets.dll) in ConfigFileCreation.exe: 0xC0000005: Access violation reading location 0x0000000000000008. Any help or suggestions would be appreciated.