Results 1 to 7 of 7

Thread: focusInEvent()

  1. #1
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default focusInEvent()

    I am reimplementing focusInEvent(QFocusEvent * event ) on a QTextEdit but seem to have lost the glowing edge (or visual marker that it has focus) in the process.

    Do I need to pass the event on? or make another call in focusInEvent() to get the graphical cue?

    Bob

    EDIT: Side note, I am reimplementing the widget so I can signal to another widget when focus is grabbed. It appeared reimplementing it and catching the event was the only way to do this. Is there another way?
    Last edited by coderbob; 24th December 2007 at 05:32.

  2. The following user says thank you to coderbob for this useful post:

    nithinin2001 (25th December 2007)

  3. #2
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: focusInEvent()

    Yes, After you post your signal in focusInEvent() just invoke QTextEdit::focusInEvent(e). This shall do the required GUI thing for you.
    Let your work talk for you

  4. #3
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: focusInEvent()

    I knew it was something of the sort but just could not recall.

    Thank you.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: focusInEvent()

    Quote Originally Posted by coderbob View Post
    EDIT: Side note, I am reimplementing the widget so I can signal to another widget when focus is grabbed. It appeared reimplementing it and catching the event was the only way to do this. Is there another way?
    How about QApplication::focusChanged() signal?

  6. #5
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: focusInEvent()

    Quote Originally Posted by wysota View Post
    but wysota, connecting to this signal would cause the slot to be invoked for every focus change, right? if that is the case, the slot should check every time that the newWidget is of the new custom type before notification. This would make things inefficient right?
    Let your work talk for you

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: focusInEvent()

    Quote Originally Posted by jogeshwarakundi View Post
    This would make things inefficient right?
    I don't think that it will be noticeable to the user. This slot isn't going to be called millions of times.

  8. The following user says thank you to jacek for this useful post:

    jogeshwarakundi (25th December 2007)

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: focusInEvent()

    Quote Originally Posted by jogeshwarakundi View Post
    but wysota, connecting to this signal would cause the slot to be invoked for every focus change, right? if that is the case, the slot should check every time that the newWidget is of the new custom type before notification. This would make things inefficient right?
    A single signal processing is heavier than the slot you are going to connect to it, so the overhead of actually calling the slot is minimal.

  10. The following user says thank you to wysota for this useful post:

    jogeshwarakundi (25th December 2007)

Similar Threads

  1. QLineEdit and focusInEvent
    By fuzzywuzzy01 in forum Qt Programming
    Replies: 5
    Last Post: 16th August 2007, 23:05
  2. Qt 3 : focusInEvent (QFocusEvent * e)
    By xplizion in forum Newbie
    Replies: 8
    Last Post: 2nd March 2006, 13:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.