Results 1 to 5 of 5

Thread: Signal emits, but Slot seems to ignore it...

  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Question Signal emits, but Slot seems to ignore it...

    Hello everybody,

    i've just recently stumbled into a problem, neither me nor my colleagues could solve.

    For a mobile application, I created a Downloader class that emits a signal when a file has been saved.
    This signal is connected to a slot in another class which updates some info about the downloaded file.
    The call to connect() returned true, and the signal gets emitted, but the slot seems to completely ignore the signal.
    I tested the signal by connecting it to a slot in the same class, and that slot is called.

    Iam seriously stuck right now.
    Maybe one of you can spot my error.

    a minimal compilable example is included
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Signal emits, but Slot seems to ignore it...

    How long does tmptrk live?
    Answer that question and you have solved your problem :-)

  3. #3
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Signal emits, but Slot seems to ignore it...

    oh my, thanks a lot.
    I feel like a total idiot right now, how could I possibly not see that?
    again thx a lot

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signal emits, but Slot seems to ignore it...

    How long does tmptrk live?
    Can you throw more light on that ? I am not aware of tmptrk...

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Signal emits, but Slot seems to ignore it...

    The poster created an object (tmptrack) on the stack within the scope of a function. The object got deleted before a signal could be sent.
    Solutions are to use the stack but in such a way that the object has a long enough lifetime or to use the heap.

    Qt Code:
    1. QList<Track*> AmzHandler::getTracklist()
    2. {
    3. // ...
    4.  
    5. Track tmptrk(QObject::tr("123456"));
    6.  
    7. // ...
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Signal connected to slot (or signal)
    By Althor in forum Newbie
    Replies: 2
    Last Post: 6th July 2010, 10:00
  2. Replies: 2
    Last Post: 14th August 2009, 19:54
  3. Some Signal Ignore
    By nicolas1 in forum Qt Programming
    Replies: 2
    Last Post: 31st December 2008, 02:07
  4. Replies: 1
    Last Post: 8th November 2007, 17:11
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.