PDA

View Full Version : How to call the added QWidget of QGridLayout.



minsoub
9th March 2010, 08:44
Hi, ALL.

I 'm tired call the added QWidget of QGridLayout.

How I can call the added QWidget of QGridLayout?

follow the source.

qDebug() is print 0.



grid = new QGridLayout;
for (j=0; j<i; j++) {
label = new QLabel(QString("Index %1").arg(j+1));
ed = new QLineEdit;
grid->addWidget(label, j, 0);
grid->addWidget(ed, j, 1);
}
b = new QPushButton("Put");
grid->addWidget(b, i, 0, 1, 2);

QList<QPushButton *> allPButtons = qFindChildren<QPushButton*> ( grid ); //grid->findChildren<QPushButton *>();
QList<QLabel *> allLabel = qFindChildren<QLabel*> ( grid ); // grid->findChildren<QLabel *>();
QList<QLineEdit *> allLine = qFindChildren<QLineEdit*> ( grid ); // grid->findChildren<QLineEdit *>();

qDebug() << "label count : " << allLabel.count();
qDebug() << "QLineEdit count : " << allLine.count();

for (j=0; j<allPButtons.count(); j++) {
delete allPButtons[j];
}
for (j=0; j<allLabel.count(); j++) {
delete allLabel[j];
}
for (j=0; j<allLine.count(); j++) {
delete allLine[j];
}