PDA

View Full Version : CSS won't work after intallEventFilter()



MorrisLiang
5th May 2010, 15:22
This is how it looks like,if I comment out the code:

ui.myText->installEventFilter(this);
http://i960.photobucket.com/albums/ae82/liangmorr/withoutFilter.png

This is how it looks like,if I install the event filter:
http://i960.photobucket.com/albums/ae82/liangmorr/installedfilter.png

and the implenmentation of evetFilter is just:

bool MyWindow::eventFilter(QObject* target,QEvent* event){return true;}

It's not just QTextEdit,I also test the other QWidget.All behaves the same:if I install eventfilter,then it's stylesheet is gone.

I apply the style sheet by calling:


QFile stylesheet("myCSS.css");
stylesheet.open(QFile::ReadOnly);
qApp->setStyleSheet(stylesheet.readAll());
stylesheet.close();

And I also set the stylesheet directly in the qt desiner,instead loading external file.
The problem still happens.

So,anyone has come cross this weird thing?Any solution?

squidge
5th May 2010, 15:35
So your blocking all events, but expecting the widget to behave as normal? :confused:

Now if you return false, you will not be filtering any events, so your CSS should work as designed.

MorrisLiang
5th May 2010, 16:51
Oh,my....I make a mistake....I thought "return false" means to filter out the event...
Thanks~