hello.
I'm trying to customize the widgetbox widget of the qt designer for my scope.
I see that the widgetbox is a treeview with his category model, inside each item in the category model there is a widget class.
this widget class is a listview item that can store one or more listview items (with an icon, name ecc..).
this widget class has a custom delegate , like
bool CustomItemDelegate
::editorEvent(QEvent *event,
{
((WidgetBoxCategoryModel*)modelx->sourceModel())->refresh();
m_strName = widget.name();
bool CustomItemDelegate::editorEvent(QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index)
{
const QSortFilterProxyModel* modelx =
static_cast<const QSortFilterProxyModel*>(index.model());
QDesignerWidgetBoxInterface::Widget widget =((WidgetBoxCategoryModel*)modelx->sourceModel())->widgetAt(index);
((WidgetBoxCategoryModel*)modelx->sourceModel())->refresh();
m_strName = widget.name();
To copy to clipboard, switch view to plain text mode
particulary i have a problem in this row:
QDesignerWidgetBoxInterface::Widget widget =((WidgetBoxCategoryModel*)modelx->sourceModel())->widgetAt(index);
indeed the index is the index of the listview items (widget)for the current category items and not the index in the items model (that is a list of category with a child widget)of the treeview if i have more than one category.
in this mode , if i have more of one category ,a widget with an index 1 is the first category,widget 1 but is also the second category with with widget 1!!
How i can correct?
i see that in the indexof there is amethod child , can be useful?
thanks.
Bookmarks