A part of my implementation is as the following:
{
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 ...
}
}
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 ...
}
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks