PDA

View Full Version : Item Delegate Editor Size



QAlex
19th April 2010, 16:43
Hi,
I'm writing a project with a model and an item delegate to work on model's data.
The model is a tree. When I click on an item, I obtain a data editor in the middle
of a window. In order to set the graphical parameters of the editor, I reimplemented
the slot updateEditorGeometry.



void TableDataDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
// LUTEditor *editorInstance = static_cast<LUTEditor*>(editor);
// if(!editorInstance->NameLabel->text().isEmpty()/*.contains("LUT")*/)
// editor->setGeometry(0,0,800,800);
// else

editor->setGeometry(0,0,400,800);

editor->setSizePolicy(QSizePolicy::Preferred,QSizePolicy:: Preferred);
editor->setParent(pedit);
editor->show();
}

In this way, the slot fixes the size to 400x800,
for all the editors opened.
This is my problem:
I have different kinds of editors, and I'd like to set a different size
for each type (or at least for 2 types), but I don't know how to distinguish
the different types from this slot.
I tried with static_cast, as you can see in the comments,
but this gives some problems (the executable crashes).

Can someone give me a suggestion on how to solve this problem?

Than you very much,
QAlex