Hi
I have created an app , where I click a node of a tree, it would open a website.
my problem is that , it should work only for a particular node, but currently it works for every node.
the code for creating the tree is

Qt Code:
  1. //creates a child of a root
  2. QTreeWidgetItem* SettingsTree::createItem(const QString &text, QTreeWidgetItem *parent, int index)
  3. {
  4. QTreeWidgetItem *after = 0;
  5. if (index != 0)
  6. after = childAt(parent, index - 1);
  7.  
  8. if (parent)
  9. item = new QTreeWidgetItem(parent, after);
  10. else
  11. item = new QTreeWidgetItem(this, after);
  12.  
  13. item->setText(0, text);
  14. return item;
  15. }
  16.  
  17.  
  18. //finds the child at particular index
  19. QTreeWidgetItem *SettingsTree::childAt(QTreeWidgetItem *parent, int index)
  20. {
  21. if (parent)
  22. return parent->child(index);
  23. else
  24. return topLevelItem(index);
  25. }
  26. //tree 1 created
  27. QTreeWidgetItem* SettingsTree::eBeamTREE()
  28. {
  29.  
  30. root->setText(0,"EBEAM GALLERY");
  31. for(int i=0;i<1;i++)
  32. {
  33.  
  34. createItem("Art & Design",root,0);
  35. createItem("Classroom Tools",root,1);
  36. createItem("Dynamic Content",root,2);
  37. createItem("Geography",root,3);
  38. createItem("Health",root,4);
  39. createItem("History & Social Studies",root,5);
  40. createItem("Literature & Language Arts",root,6);
  41. createItem("Mathematics",root,7);
  42. createItem("Music & Theatre",root,8);
  43. createItem("Recreation & Games",root,9);
  44. createItem("Science",root,10);
  45. createItem("Backgrounds",root,11);
  46. createItem("Tips & Tricks",root,12);
  47.  
  48. }
  49. return root;
  50. }
  51.  
  52. //tree 2
  53. QTreeWidgetItem* SettingsTree::eBeamMYGALLERY()
  54. {
  55.  
  56. root1->setText(0,"MY GALLERY");
  57. for(int i =0;i<1;i++)
  58. {
  59. createItem("My Gallery",root1,0);
  60. }
  61. return root1;
  62. }
  63.  
  64.  
  65. //tree3
  66. QTreeWidgetItem* SettingsTree::eBeamRESOURCETREE()
  67. {
  68. root2->setText(0,"RESOURCES");
  69. for(int i=0;i<1;i++)
  70. {
  71. child = createItem("eBeam Web Resources",root2,0);
  72.  
  73. }
  74. root2->setFlags(Qt::ItemIsSelectable);
  75. return child;
  76. }
To copy to clipboard, switch view to plain text mode 

Codeto connect to a website
Qt Code:
  1. void MainWindow::openwebsite()
  2. {
  3. while(*it)
  4. {
  5. if((*it)->text(0)=="eBeam Web Resources")
  6. {
  7. QUrl url(QString("http://www.e-beam.com/education/web-resources.html"));
  8. bool flag = QDesktopServices::openUrl(url);
  9. if (flag == false)
  10. {
  11. qDebug()<<"Error Opening the website";
  12. }
  13. }
  14.  
  15. ++it;
  16. }
  17. }
To copy to clipboard, switch view to plain text mode