Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt for Visual Studio Add-In can not connect signals to slots that depend on conditional compilation
Forum Updated to NodeBB v4.3 + New Features

Qt for Visual Studio Add-In can not connect signals to slots that depend on conditional compilation

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Good Guy
    wrote on last edited by
    #1

    It looks logical that application debug version uses more signals and slots to monitor application execution than release one. Application may also have different debug modes that give more attention to specific problems.
    I have such application that I compile with Visual Studio. I have signal that I want to use when some debug mode is enabled. I use preprocessor definition, lets say, DEBUG_MODE_1. I create slot in following way:

    #ifdef DEBUG_MODE_1
    private slots:
    
       void MyDebugSlot(void);
    #endif
    

    I use Visual Studio project settings to add DEBUG_MODE_1 preprocessor definition when I compile in some debug configuration. The problem is that when I use connect with MyDebugSlot, I receive following error message: QObject::connect: No such slot

    It however connects successfuly when I comment #ifdef statement.
    So, it looks like Qt for Visual Studio Add-In ignores project preprocessor definition, and as a result I have to remove #ifdef and include a lot of not needed debugging functionality in release, or I have to modify source code manually between release and debug builds.
    Is there any way to make Qt slots dependent on preprocessor definitions in Visual Studio?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi, welcome to devnet.

      As far as I can tell the scenario you described works correctly. The add-in passes the project defines to moc and it generates or not the slot metadata, depending on the define.

      Make sure you define the symbol in Project Properites -> C/C++ -> Preprocessor -> Preprocessor Definitions. The add-in will not pick it up otherwise e.g. if you define it in some include file or manually via /D switch to the compiler.

      Also, which Qt/add-in version are you using? Some very old moc versions did not handle preprocessor correctly.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Good Guy
        wrote on last edited by
        #3

        Hi, thansk for your reply. I use Visual Studio 2013 and Qt Visual Studio Add-In 1.2.4. Qt version is Qt 5.5.1 MSVC2013 64bit (one I downloaded with Qt Maintenance tool). I define preprocessor at preprocessor definitions for Debug configuration. Visual Studio intellisence recognizes it, and project compiles successfuly.
        May be I have to force Visual Studio to re-run moc somehow if it is not done automatically during build process?

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The moc is re-run whenever a change in the header occurs. You can clean the project and rebuild but I doubt it will change anything.
          Can you inspect the generate moc_* files to see if your slot is there for the release and debug builds?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Good Guy
            wrote on last edited by
            #5

            Well, I was able to force it to work by removing Q_OBJECT, rebuild and adding Q_OBJECT back. So, it looks like Qt for Visual Studio Add-In doesn't update Generated Files correctly.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved