Hello!

I'm having a work with QTreeWidget and I found a problem here in locating an item on it by one of its texts. The idea is the following:

I created a QTreeWidget and I decided to read from a txt file some columns and create items and sub-items in the QTreeWidget with the data collected in the txt. The idea is that in each line of the txt there are some parameters base on date values (02/12/2011, e.g.). The algorithm is supposed to do a research in the QTreeWidget each time a new line is read in the txt and see if there is already an item related to that date. If there is not, a new item is created with that new date and the rest of the line data is used to create a child on that item. By the other hand, if an item with that date already exists, than instead of creating a new item with that date and a child with the rest, the algorithm should create only the child under the already existing item.

But I'm having difficulties in creating a search mechanism to see if there is already an item related to that date. Everything else I already have. I tested the function QList<QTreeWidgetItem *> QTreeWidget::findItems ( const QString & text, Qt::MatchFlags flags, int column = 0 ) const (p.s.: where is the button for Qt functions and classes?), but its not working. By the moment, here is what I have:

Qt Code:
  1. void AlarmManagment::readExistingAlarms()
  2. {
  3. v_rewr->openRead2("./Config/Alarms.txt");
  4.  
  5. name: leituraall = v_rewr->Read();
  6.  
  7. vr_data = leituraall.section('\t',0,0);
  8. vr_semana = leituraall.section('\t',1,1);
  9. vr_hora = leituraall.section('\t',2,2);
  10. vr_smalldescription = leituraall.section('\t',3,3);
  11.  
  12. if (!vector_String1.contains(vr_data))
  13. {
  14. vector_String1.push_back(vr_data);
  15. addRoot(vr_data, vr_semana, vr_hora, vr_smalldescription);
  16. qDebug() << "Item normal sendo colocado: " << vr_data;
  17. }
  18. else
  19. {
  20. a = ui->Listofalarms->findItems(vr_data,Qt::MatchExactly,1);
  21. qDebug() << "item ja exite: " << vr_data;
  22. addChild(a.front(),vr_semana,vr_hora,vr_smalldescription);
  23. }
  24.  
  25. if (!v_rewr->attheEnd()) goto name;
  26. }
  27.  
  28. void AlarmManagment::addRoot(QString data, QString semana, QString hora, QString smadesc)
  29. {
  30. QTreeWidgetItem *itm = new QTreeWidgetItem(ui->Listofalarms);
  31. itm->setText(0,data);
  32.  
  33. itm2->setText(0,semana);
  34. itm2->setText(1,hora);
  35. itm2->setText(2,smadesc);
  36.  
  37. itm->addChild(itm2);
  38. }
  39.  
  40. void AlarmManagment::addChild(QTreeWidgetItem *parent, QString sem, QString hour, QString smaldescription)
  41. {
  42. itm2->setText(0,sem);
  43. itm2->setText(1,hour);
  44. itm2->setText(2,smaldescription);
  45.  
  46. parent->addChild(itm2);
  47. }
To copy to clipboard, switch view to plain text mode 

while:
Qt Code:
  1. QList<QTreeWidgetItem *> a;
To copy to clipboard, switch view to plain text mode 

I'm having problems in dealing with this QList of QTreeWidgetItem in terms of finding the item that has the date in question.