Results 1 to 12 of 12

Thread: Item in a DLL not getting events

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    27
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Item in a DLL not getting events

    The object that doesnt get the event ....well ,I wont simplify it just in case it s important .
    I have an abstract class (lets call it A) that inherits QGraphicsItem , then 2 clases (non abstract) that virtually inherit A (B,C) ,and then a class that inherits B and C (D) . (None is Q_OBJECT) .
    In my application , I use only pointers to tha abstract base class.
    The other items : one inherits QGraphicsTextItem (inherits QObject) ,and the other is a QGraphicsLineItem (doesnt inherit QObject) .

    I realy dont know why it doesnt work
    Thanks again.
    If God has friends ,then I cant be God.

  2. #2
    Join Date
    Apr 2006
    Location
    Denmark / Norway
    Posts
    67
    Thanks
    3
    Thanked 12 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Item in a DLL not getting events

    And the event it doesn't recieve?

    Have you tried adding the Q_OBJECT macro to the classes to see what happens? It might be that since you don't have the macro, some events sent through signals/slots are not reciveved? I'm unsure about this...

  3. #3
    Join Date
    Jul 2008
    Posts
    27
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Item in a DLL not getting events

    Quote Originally Posted by luf View Post
    And the event it doesn't recieve?

    Have you tried adding the Q_OBJECT macro to the classes to see what happens? It might be that since you don't have the macro, some events sent through signals/slots are not reciveved? I'm unsure about this...
    Sorry ,I forgot that .They dont seem to recieve any event. If I click them,nothing happens , I had rubber band drag (or however it s called) and it doesnt work now .It s just like if the item wasnt there .
    And about Q_OBJECT....maybe I try it if I have some time ,but I dont like that solution ,why should a graphics view item that was working perfectly have to inherit QObject and add that macro in order to be able to work in a DLL ? Maybe there is a reason ,I dont know ,but I wouldnt like that handicap.
    Thanks , hopefuly I solve this......soon ,but I m a little bit faithless.
    If God has friends ,then I cant be God.

  4. #4
    Join Date
    Jul 2008
    Posts
    27
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Item in a DLL not getting events

    -_- ,I think I have found the problem or at least a fix.I had a constructor without parameters like this:
    Node()
    {
    }

    Tha should implicitly call QGrapchicsItem() , what actualy is QGraphicsItem ( QGraphicsItem * parent = 0 ) .I had another constructor :
    Node (...... ,QGraphicsScene * scene =0 ,QGraphicsItem * parent=0)
    that called QGraphicsItem(parent) ,but parent was always null .So ,if I use the default contructor ,the events dont work ,if I use the other ,they do .It doesnt make any sense to me .I ll try to explicitly call the default base class constructors to see if it works that way ,otherwise,I ll just use the constructors with parameters .
    Anyone knows why this happens?
    If God has friends ,then I cant be God.

  5. #5
    Join Date
    Apr 2006
    Location
    Denmark / Norway
    Posts
    67
    Thanks
    3
    Thanked 12 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Item in a DLL not getting events

    Hi

    What happens is that when the item doesn't have a parent, it won't recieve events unless it has focus. (e.g. clicked on, selected or programatticly has focus)

    When programming with Qt it's a good practice to have a parent for all objects, so that objects are deleted if the parent is deleted...

    Leif

  6. #6
    Join Date
    Jul 2008
    Posts
    27
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Item in a DLL not getting events

    Uhm.....So the thing was the items werer not getting focus....But other parentless items worked fine .
    Thanks for the tips.
    If God has friends ,then I cant be God.

Similar Threads

  1. Replies: 2
    Last Post: 1st August 2008, 16:58
  2. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  4. Replies: 1
    Last Post: 21st August 2007, 16:25
  5. Replies: 1
    Last Post: 19th April 2007, 22:23

Tags for this Thread

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.