PDA

View Full Version : Create Row dynamically in QListWidget



sijithjames
17th July 2011, 12:03
Hi,

I want to create a custome widget. Please help by giving some idea.
My intention is to make a Listwidget which shows some Information and when clicking particulat row it have to show the details coresponding to that row by creating a new area(Row or text edit) immediately below the selected row and pull the other rows below the selected row to down after the created new area.
In attachment when I click row Nancy (consider it as row) her details is coming below the selected row. Please help on this

Santosh Reddy
18th July 2011, 01:02
You could do this by using QTableWidget, considering the attachment you posted, it has 8 columns and multiple rows, so here is how you can do this

- Create QTableWidget with 8 columns, and how ever row you want to
- Then set the row selection behavior (tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows ); )
- When user selects any item of given row (you could used void itemClicked(QTableWidgetItem * item) signal)
- Create a new item with your required details, and insert it right below the selected item, i.e. the next row
- For the new detailed item created, set the column span to 8, such that it will stretch the whole table width (tableWidget->setSpan(new_row, 0, 1, 8); )

You now can see what you wanted, just take care of removing and deleting the new detailed item when use selects an another item, next time.