PDA

View Full Version : The delegated widgets become hidden



fulbay
20th December 2010, 09:54
Hello,

I have some delegated items on a tree widget. When I assign installEventFilter() function to those delegated items, they become invisible :( Might it be a bug or is there a way to overcome this problem? :confused:

Thanks a lot for your help...

Lykurg
20th December 2010, 12:14
Most likely your event filter is buggy. Did you call the base class implementation if you don't react on a specific event?

fulbay
20th December 2010, 12:22
A part of my implementation is as the following:


bool Mission::eventFilter(QObject *obj, QEvent *event)
{
QTreeWidgetItem *t;

if (event->type() == QEvent::MouseButtonPress)
{
QComboBox *comboBox = dynamic_cast<QComboBox*>(obj);
if(comboBox != NULL)
{
t = findComboBox(comboBox);
if(t->parent() == treeWidgetItemName) // route
{
dynamic_cast<QComboBox*>(treeWidgetMission->itemWidget(t, 1))->setStyleSheet(QString::fromUtf8("background-color: rgb(160, 160, 160);\n"));
dynamic_cast<QLineEdit*>(treeWidgetMission->itemWidget(t, 0))->setStyleSheet(QString::fromUtf8("background-color: rgb(160, 160, 160);\n"));
}
t->setSelected(true);
treeWidgetMission->setCurrentItem(t);
}
//else ...
}
}

Is there a bug?

Thanks a lot...

Note: Even if I comment out the code in eventFilter(), the same problem exists. If I comment out the code where I assign installEventFilter() method to the delegated widgets, there is no problem, but, of course, eventFilter() is not caught by those widgets then.

Lykurg
20th December 2010, 12:36
Is there a bug?
Yes, you need to call the base class impelemtation. Something like:
return QObject::eventFilter(obj, event); It is also described in QObject::installEventFilter().

fulbay
20th December 2010, 12:53
Oh, yes! Thanks! This help is great to me :)