Results 1 to 4 of 4

Thread: Signal emitted more than once?

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Signal emitted more than once?

    Hi

    I have a GUI front end controlling MyClass. MyClass is created when I load an input file and the signal/slot connections are made. A push button is used to run a function from my object.

    This works fine , i.e the function only runs once when the button is pushed.

    If I then create another instance of MyClass by loading a new data file, I delete the current instance of MyClass and create a new one. Now when I click the push button, the function runs twice.

    Any ideas why this is?

    Regards

  2. #2
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Signal emitted more than once?

    Without seeing your code, I'd say you probably need to call disconnect() for the object you're deleting. If you keep deleting and creating instances, does the number of signals emitted increase proportionally?

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

    dbrmik (13th March 2009)

  4. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signal emitted more than once?

    maybe in generated ui_xxx.h contains autoconnection and you add a new one in your code. anyway, as said above without code it's hard to say
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    dbrmik (13th March 2009)

  6. #4
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Signal emitted more than once?

    Thanks Jim for the quick reply, yes the number of times the signal is emitted is equal to the number of times the object is created/deleted.

    Yes I do need disconnect().

    I have found the problem. The push button was connected to a function in my GUI which calls the MyClass member function. I need to disconnect this signal

    Thanks Jim

Similar Threads

  1. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  2. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  3. Program crash when a signal is emitted
    By croscato in forum Qt Programming
    Replies: 7
    Last Post: 22nd November 2008, 22:24
  4. creating treeWidgetItem using emitted signal from thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:37
  5. Replies: 5
    Last Post: 9th March 2007, 12:51

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.