Results 1 to 3 of 3

Thread: CSS won't work after intallEventFilter()

  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question CSS won't work after intallEventFilter()

    This is how it looks like,if I comment out the code:
    Qt Code:
    1. ui.myText->installEventFilter(this);
    To copy to clipboard, switch view to plain text mode 


    This is how it looks like,if I install the event filter:


    and the implenmentation of evetFilter is just:
    Qt Code:
    1. bool MyWindow::eventFilter(QObject* target,QEvent* event){return true;}
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. QFile stylesheet("myCSS.css");
    2. stylesheet.open(QFile::ReadOnly);
    3. qApp->setStyleSheet(stylesheet.readAll());
    4. stylesheet.close();
    To copy to clipboard, switch view to plain text mode 

    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?
    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CSS won't work after intallEventFilter()

    So your blocking all events, but expecting the widget to behave as normal?

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

  3. The following user says thank you to squidge for this useful post:

    MorrisLiang (5th May 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CSS won't work after intallEventFilter()

    Oh,my....I make a mistake....I thought "return false" means to filter out the event...
    Thanks~
    It's not the goodbye that hurts,but the flashback that follow.

Similar Threads

  1. QT QSS ui work
    By davejh in forum Jobs
    Replies: 2
    Last Post: 12th May 2010, 16:31
  2. Why does this not work?
    By lnxusr in forum Newbie
    Replies: 8
    Last Post: 18th December 2009, 18:53
  3. Replies: 2
    Last Post: 13th December 2009, 20:27
  4. tr with #define..it can work?
    By mattia in forum Newbie
    Replies: 9
    Last Post: 4th February 2008, 11:15
  5. Replies: 3
    Last Post: 15th January 2008, 12:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.