In my example i have a tableview widget.
the server send a xml protocoll tothe client. in these protocoll are the items from the combobox.
Now i have 2 functions
addComboItems();
and createEditor();
addCcmboItems() Example:
{
if(LineEditDelegate *le = qobject_cast<LineEditDelegate *> (wg))
{
wg = le->qw_editor;
}
if(Combobox *cb = qobject_cast<ComboBox *> (wg))
{
cb->addItem(value, text);
}
}
void myclass::addComboItems(int id, QString text, QString value)
{
QWidget *wg = object;
if(LineEditDelegate *le = qobject_cast<LineEditDelegate *> (wg))
{
wg = le->qw_editor;
}
if(Combobox *cb = qobject_cast<ComboBox *> (wg))
{
cb->addItem(value, text);
}
}
To copy to clipboard, switch view to plain text mode
Constructor from LineEditDelegate:
: QStyledItemDelegate(parent)
{
qw_editor = WidgetHelper::createFormWidget(...);
}
LineEditDelegate::LineEditDelegate(QDomElement formElement, QObject *parent)
: QStyledItemDelegate(parent)
{
qw_editor = WidgetHelper::createFormWidget(...);
}
To copy to clipboard, switch view to plain text mode
createformWIdget creates the Combobox QCOmbobox *cb = new QCombobox(this); ...
And the LineEditDelegate::createEditor() example:
{
QWidget *editor
= WidgetHelper
::createFormWidget(..., parent
);
...
...
return editor;
}
QWidget* LineEditDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QWidget *editor = WidgetHelper::createFormWidget(..., parent);
...
...
return editor;
}
To copy to clipboard, switch view to plain text mode
And my Problem is, editor from createEditor has a different pointer as cb in addComboItems the items are not visible in the widget.
The Problem is addComboItem is calling before createEditor.
There are any ways to get the pointer from createEditor?
I Hope this question is better to understand my problem.
Bookmarks