PDA

View Full Version : QListWidget in QtableView with scrollbar



jwill222
8th May 2015, 18:58
To make a long story short, I need an answer to this previous asked question -> http://www.qtcentre.org/threads/45101-QListWidget-Delegate-in-QTableView-Column-How-To-Scroll

I'm getting the widget to appear in the qtableview, but I can't use the vertical scrollbar.

d_stranz
8th May 2015, 22:56
Are you embedding actual QListWidget instances in the cells of the table, or are you doing as the author of that post did and creating a delegate that simply paints the appearance of a QListWidget into the cell?

jwill222
11th May 2015, 18:04
The latter. Is that the wrong way to go about it? I basically just want to have the listwidget in the cell so the user can scroll through it.

d_stranz
12th May 2015, 03:25
The latter. Is that the wrong way to go about it?

Yes. All you are getting is a picture of the widget which is being painted into the cell as an image. It's not a widget, you can't interact with it.

There are two things you can do:

1 - Create actual list widgets and set them as the index widgets for the cells you want. QTableView::setIndexWidget() If the table is of any significant size, you will take a huge preformance hit. The widgets are disconnected from the model, so you have to manually update the widgets when the model changes, and if the model needs to change based on selections from the list, you'll need to do that yourself as well.

2 - Create an item delegate based on a list widget and install that on the cells where needed. Item delegates are intended to be used when editing a cell's content, and are normally not visible when the cell does not have focus.

Neither choice is optimal for what you are trying to do.