QListWidget Delegate in QTableView Column How To Scroll
I have created a delegate class for the QListWidget and I have added the delegate to a column of a QTableView. My scrollbars appear in my QListWidget when needed but the scroll does not appear to work. I am somewhat new to using the QTableView and delegates. Is there something, perhaps in the editorevent method that must be implemented to allow scrolling to work? If anyone has an example or can point me to something I would appreciate it.
Thanks in advance!
Re: QListWidget Delegate in QTableView Column How To Scroll
What scrollbars do you mean? The one from QTableView? What does a delegate have to do with that?
Re: QListWidget Delegate in QTableView Column How To Scroll
I have created a delegate class "CheckedListBoxDelegate : public QStyledItemDelegate" and I am creating a QListWidget in the paint method to be drawn for a column in my QTableView. The scrollbars that I am talking about are the scrollbars on the QListWidget. The up/down arrows on the QListWidget's scrollbars are being drawn but do not allow the widget to scroll.
Code:
void CheckedListBoxDelegate
::paint(QPainter* painter,
const QStyleOptionViewItem
& option,
const QModelIndex
& index
) const {
list_widget.resize(option.rect.width(),option.rect.height());
{
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
if(list.contains(str))
{
item->setCheckState(Qt::CheckState::Checked);
}
else
{
item->setCheckState(Qt::CheckState::Unchecked);
}
list_widget.addItem(item);
}
painter->save();
painter->setClipRect(option.rect);
painter->translate(option.rect.topLeft());
list_widget.render(painter);
painter->restore();
}
Re: QListWidget Delegate in QTableView Column How To Scroll
Quote:
Originally Posted by
kbatch
I have created a delegate class "CheckedListBoxDelegate : public QStyledItemDelegate" and I am creating a QListWidget in the paint method to be drawn for a column in my QTableView. The scrollbars that I am talking about are the scrollbars on the QListWidget. The up/down arrows on the QListWidget's scrollbars are being drawn but do not allow the widget to scroll.
You are just rendering the looks of a widget so it seems obvious any interaction with it will fail since the widget is not really there.
Re: QListWidget Delegate in QTableView Column How To Scroll
Yes, that has occurred to me. Any suggestions as to how someone may go about doing what I am attempting to do?
Re: QListWidget Delegate in QTableView Column How To Scroll
First I would ask for a purpose of doing what you are doing. Whatever it is, I don't think embedding a list widget inside a table view is a good solution. I would probably rather use QTreeView or a different solution.