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.

Qt Code:
  1. grid = new QGridLayout;
  2. for (j=0; j<i; j++) {
  3. label = new QLabel(QString("Index %1").arg(j+1));
  4. ed = new QLineEdit;
  5. grid->addWidget(label, j, 0);
  6. grid->addWidget(ed, j, 1);
  7. }
  8. b = new QPushButton("Put");
  9. grid->addWidget(b, i, 0, 1, 2);
  10.  
  11. QList<QPushButton *> allPButtons = qFindChildren<QPushButton*> ( grid ); //grid->findChildren<QPushButton *>();
  12. QList<QLabel *> allLabel = qFindChildren<QLabel*> ( grid ); // grid->findChildren<QLabel *>();
  13. QList<QLineEdit *> allLine = qFindChildren<QLineEdit*> ( grid ); // grid->findChildren<QLineEdit *>();
  14.  
  15. qDebug() << "label count : " << allLabel.count();
  16. qDebug() << "QLineEdit count : " << allLine.count();
  17.  
  18. for (j=0; j<allPButtons.count(); j++) {
  19. delete allPButtons[j];
  20. }
  21. for (j=0; j<allLabel.count(); j++) {
  22. delete allLabel[j];
  23. }
  24. for (j=0; j<allLine.count(); j++) {
  25. delete allLine[j];
  26. }
To copy to clipboard, switch view to plain text mode