Results 1 to 17 of 17

Thread: Using custom events.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using custom events.

    An Optimization? i'm not sure i understand... Now i've pointed it out, you know it's an optimization? Why not telling it in the doc then?... i really don't think it's an optimisation (When registering a new event type, it's based on it's type #ID, not it's class... If internally Qt does a type check based on the class, it makes no sense... i don't even think it's possible, since QEvent is not a subclass of QObject, and since my subclasses don't Q_OBJECT, it's not possible to get the superclass at runtime.

    Explain me, i really hate to get vague guesses

    Pierre.

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

    Default Re: Using custom events.

    Quote Originally Posted by hickscorp View Post
    An Optimization? i'm not sure i understand...
    There is no point in tracking mouse position on the items (which requires coordinate transformations and collision detection) if you know the mouse is not in any of the views that hold the items. There is no point in tracking the mouse to detect hover events if you know the mouse is not over the item, etc. I'd assume it's exactly the same for widgets, although it might be a bit different as there is no scene equivalent for widgets so you'd post the event directly to the widget and this will probably just work (although Qt will not try to detect hover events by itself).

    Now i've pointed it out, you know it's an optimization?
    It's just logical to assume so. Qt is open source, you can easily verify my assumption by reading its source code.

    Why not telling it in the doc then?...
    If every detail was covered in the docs and every possible abuse of Qt was warned about in the docs, then the docs would have several gigabytes of volume and there would still be creative people who would invent new ways of abusing Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using custom events.

    Quote Originally Posted by wysota View Post
    There is no point in tracking mouse position on the items (which requires coordinate transformations and collision detection) if you know the mouse is not in any of the views that hold the items. There is no point in tracking the mouse to detect hover events if you know the mouse is not over the item, etc. I'd assume it's exactly the same for widgets, although it might be a bit different as there is no scene equivalent for widgets so you'd post the event directly to the widget and this will probably just work (although Qt will not try to detect hover events by itself).
    It's just logical to assume so. Qt is open source, you can easily verify my assumption by reading its source code.
    If every detail was covered in the docs and every possible abuse of Qt was warned about in the docs, then the docs would have several gigabytes of volume and there would still be creative people who would invent new ways of abusing Qt.
    i'm not sure you see the problem.... The mouse is tracked, whatever if there is a point or not (QGraphicsItem has the hovering methods virtual, which allows subclassing + overriding). it's not a mouse tracking related problem. it's an custom event propagation problem. i could be trying to post ANY other kind of event (Even NOT hover-related), as long as they are custom, derived from a class itself derived from QEvent, it won't work.

    Try it yourself. Make a class A, derived from QEvent. Make a class B, derived from A. Register a custome event type assigned to either A or B. Post a B. (You'll never receive it in your target, whatever you're using post or send). Try this outside any QGraphics context, again: i'm really not talking about any hover / mouse / move thingy stuff.

    @high_flier: Sorry, i don't understand your answer. Are you misstaking me with me? You're saying i'm suggesting myself something? XD

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

    Default Re: Using custom events.

    Only GUI-related events are propagated. Custom events are not GUI related.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using custom events.

    Quote Originally Posted by hickscorp View Post

    @high_flier: Sorry, i don't understand your answer. Are you misstaking me with me? You're saying i'm suggesting myself something? XD
    I meant agathiyaa.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Jun 2010
    Location
    India
    Posts
    50
    Thanks
    1
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using custom events.

    Hi...

    I have found the exact problem in your code.

    Qt ( C++) allows / accepts subclasses of QEvent, Also sub-subclasses / throughout the inheritance hierarchy
    It seems "HoverEnter" & "HoverLeave" is defined or used somewhere else. If you try different name or
    Qt Code:
    1. class HoverEnterEvent : public AWBObject::Event {
    2. public:
    3. HoverEnterEvent () : Event(AWBObject::HoverEnter) {};
    4. };
    To copy to clipboard, switch view to plain text mode 
    it should work for you as is.(Note: AWBObject::HoverEnter)

    Please give a try and let us know. It worked for me.
    Last edited by agathiyaa; 17th June 2010 at 19:35.

Similar Threads

  1. Pass custom events to another process
    By TTGator in forum Qt Programming
    Replies: 9
    Last Post: 14th January 2009, 22:02
  2. Capture events in a custom delegate
    By vfernandez in forum Qt Programming
    Replies: 9
    Last Post: 19th March 2008, 05:33
  3. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 10:52
  4. custom events
    By momesana in forum Qt Programming
    Replies: 5
    Last Post: 30th January 2008, 23:20
  5. Posting custom events to a subclass of QThread
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2006, 15:49

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.