Results 1 to 9 of 9

Thread: Signals/Slots stopped working

  1. #1
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Signals/Slots stopped working

    Hello,

    I'm working on an application that uses signals and slots. We are writing our app using Qt 4.1.0 in MS Visual Studio 2003.

    My application was working well last week. I had one class that emitted signals that were recieved by another class's slots. It was all very cool and I was happy.

    This week our project got split so that my two classes are in different Visual Studio project (.vcproj) files. Now when my one class emits a signal, the other does not pick it up.

    If anyone has any ideas about what may have happened and how I could fix this, I would certainly appreciate it.

    Thanks in advance,
    Jimmy

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

    Default Re: Signals/Slots stopped working

    Add "CONFIG += console" to your .pro file, compile in debug mode and check if there are some messages on the console.

  3. #3
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signals/Slots stopped working

    adding that line to the .pro file does not seem to make a difference. there are no additional messages in the output window

    Does the .pro file even get used when compiling within Visual Studio?

  4. #4
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signals/Slots stopped working

    Quote Originally Posted by Jimmy2775
    adding that line to the .pro file does not seem to make a difference. there are no additional messages in the output window

    Does the .pro file even get used when compiling within Visual Studio?
    After you modified the .pro file you did regenerate the Makefiles, didn't you?

  5. #5
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signals/Slots stopped working

    Fixed the problem.

    In case anyone else encounters this: My signals were in a dll project and slots in the exe. I changed the dll's project config to a static library (.lib) instead and the slots were able to pick up the signals again.

    Jimmy

  6. #6
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signals/Slots stopped working

    I'm not certain if .pro and makefile are applicable or relavent in this case when the VS compiler is using the .sln and .vcproj files for the build. Am I wrong in that assumption?

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Signals/Slots stopped working

    Quote Originally Posted by Jimmy2775
    Does the .pro file even get used when compiling within Visual Studio?
    Modifying the .pro file has no effect unless you re-import the project from the .pro file (the Qt-menu in visual studio).
    It's profitable to maintain the .pro file, anyway. I don't ever store any visual studio files in version control. I always keep the .pro file up-to-date and keep only "a clean Qt-project" in version control. Actually, I always even open the project in visual studio through the Qt-menu. This way I have a fully working project nevertheless I check it out to a different platform.. You don't have much use for visual studio project files in Linux.

    How did you create the connection in the first place?
    These aforementioned two classes are now in different projects, but same solution?

  8. #8
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Signals/Slots stopped working

    That is a good point about maintaining the .pro file. At this point we are only building for Windows, but that will change in time. It is probably wise to be prepared for that

    Origionally the two files were in the same solution, same project. Now they are in different projects but the same solution. I create the connection between the two in the constructor of the class with the slots. I take a pointer to the signal class as a parameter of the constructor of the slot class.

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Signals/Slots stopped working

    Ok nevermind, as the problem was already solved while I was still tapping my first post..

Similar Threads

  1. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26

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.