[Qt-interest] Tree Item view Highlighter
Sajjad
dosto.walla at gmail.com
Mon Jan 3 23:29:50 CET 2011
Hello forum,
The following topic is the follow-up which has been discussed several days
ago. I want to highlight a particular tree item based on pattern matching.
In that case i have sub-classed the QSortFilterProxyModel and over-ridden
the following function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool H3DHighlighterProxyModel::filterAcceptsRow(int source_row, const
QModelIndex &source_parent) const
{
std::cout << "In the filtration" << std::endl;
QColor highLighter = Qt::cyan;
QColor noHighLighter = Qt::white;
if(sourceModel()->data(source_parent).toString().contains(filterRegExp()))
{
std::cout << "Will be highlighted" << std::endl;
sourceModel()->setData(source_parent,QVariant(highLighter),Qt::BackgroundRole);
}
else
{
std::cout << "Will not be highlighted" << std::endl;
sourceModel()->setData(source_parent,QVariant(noHighLighter),Qt::BackgroundRole);
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
But i am not getting any high-lighting effect with the textChanged signal in
the line edit . The appropriate slot has been connected as follows:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void H3DNodeListWidget::highlightRegExpChanged()
{
QRegExp regExp(m_nodeHighlightingEditor->text(),Qt::CaseInsensitive);
m_highlightModel->setFilterRegExp(regExp);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If there is anything missing in the process or logical mistake, please mark
it out for me that i am missing.
Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110103/7b7d54a7/attachment.html
More information about the Qt-interest-old
mailing list