Hello,
I have a problem to create a dynamic number of QLabel and QLineEdit.
I have build a QList:
QList<QLineEdit*> dongleDataLineEdit;
QList<QLabel*> dongleDataLabel;
QList<QLineEdit*> dongleDataLineEdit;
QList<QLabel*> dongleDataLabel;
To copy to clipboard, switch view to plain text mode
Now, the code to generate my QLabel an QLineEdit.
void CMainWindow::setDongleDataField() {
for (int i=0; i<plainDongle->DNG_Memmory/4; i++) {
dongleDataLabel.
append(new QLabel);
}
displayDongleData();
}
void CMainWindow::displayDongleData() {
int x = 0;
for (int i; i<plainDongle->DNG_Memmory/4; i++) {
dongleDataLabel[i]->setText(tr("Value "+i));
dongleLayout->addWidget(dongleDataLabel[i], x, 0);
dongleLayout->addWidget(dongleDataLineEdit[i], x, 1);
x++;
}
}
void CMainWindow::setDongleDataField() {
for (int i=0; i<plainDongle->DNG_Memmory/4; i++) {
dongleDataLabel.append(new QLabel);
dongleDataLineEdit.append(new QLineEdit);
}
displayDongleData();
}
void CMainWindow::displayDongleData() {
QGridLayout *dongleLayout = new QGridLayout;
int x = 0;
for (int i; i<plainDongle->DNG_Memmory/4; i++) {
dongleDataLabel[i]->setText(tr("Value "+i));
dongleLayout->addWidget(dongleDataLabel[i], x, 0);
dongleLayout->addWidget(dongleDataLineEdit[i], x, 1);
x++;
}
}
To copy to clipboard, switch view to plain text mode
The problem is, my program does not start, it terminated without any error.
Can someone help me to fix the problem?
Bookmarks