Sample application - QTreeWidget, QTableWidget, QItemSelectionModel
Hello forum,
I have a dialog window with qtreewidget and qtablewidget. Whenever the user clicks any of the tree widget item, more attribute information about the tree item will be shown in the table widget.
If anyone is aware of any examples related to what i am looking for as mentioned above, please send me those reference examples.
I am trying to understand the piechart example and in the mean-time i shall be grateful if something more simpler reference example or hints shows up from anyone of you.
Regards
Sajjad
2 replies
I am using an example like this:
I insert in QTableWidget data starting from a QStringList.
- int w,h,pv,ph;
- w= d->width()/2;
- h =d->height()/2;
- pv = w-(240);
- ph= h-(120);
- QxtTableWidget *tb = new QxtTableWidget(agr);
- QStringList lista;
- lista <<"Codigo"<<"Nome"<<"Tipo Layout";
- vb->addWidget(le);
- vb->addWidget(tb);
- vb->addWidget(lb);
- tb->setColumnCount(3);
- tb->setHorizontalHeaderLabels(lista);
- agr->show();
- QPropertyAnimation *propAnimationFade = new QPropertyAnimation(agr, "geometry");
- propAnimationFade->setDuration(400);
- propAnimationFade->start();
- tb->verticalHeader()->setVisible(false);
- tb->setRowCount(1);
- tb->setItem(0,0,bitem0);
- tb->setItem(0,1,bitem1);
- tb->setItem(0,2,bitem2);
Hi,
You need to use a QTreeView,QTableView and a model(eg: QStandardItemModel to store the information). You also need a class to store the information/data(eg class Student { int m_rollNumber , QString m_name; }; etc ) and in the treeView u need to store the object of this class.
When an item/object from the treeView is selected u need to cast this object to your class and then get the information and for the particular columns in tableView u can set the values. You can try this approach to create a sample application.
You must log in to post a reply. Not a member yet? Register here!



