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. Getting "QObject::connect: signal not found" when using a signals of different libraries.
Forum Updated to NodeBB v4.3 + New Features

Getting "QObject::connect: signal not found" when using a signals of different libraries.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 4.0k Views
  • 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.
  • R Offline
    R Offline
    rkhaotix
    wrote on 16 Nov 2022, 23:30 last edited by rkhaotix
    #1

    Hey guys! I hope you all doing fine!

    I'm here to ask for help from the Qt specialists... :D

    I'm struggling to make my codebase work on Windows after refactoring the classic signal/slot connection connect(sender, SIGNAL(signal), receiver, SLOT(slot)) to the not-so-new one based on the pointer to function/method connect(sender, &SenderClass::signal, receiver, &ReceiverClass::slot).

    The code builds and works fine on Linux and macOS. But on Windows, building with MingW64 (gcc 12) and Qt 6.3.1 I get a lot of runtime errors during the application startup: qt.core.qobject.connect: QObject::connect: signal not found in BaseGraphicObject. If I keep using the software I receive similar runtime errors but now related to other classes in my project. I've managed to track where the majority of these errors occur but I have no idea how to solve them.

    First, let me give some background on how my project is built. pgModeler is divided into six library subprojects and other four app subprojects. Each executable is linked against one or more libraries. Libraries share between them their classes, namespaces, and other things. In some libraries, I do signal/slot connections by referencing classes defined in other libraries, and I think this is one of the problems.

    Being said that, the simple constructor below raises the runtime error:

    TableView::TableView(PhysicalTable *table) : BaseTableView(table)
    {
    	connect(table, &PhysicalTable::s_objectModified, this, &TableView::configureObject);
    	this->configureObject();
    }
    

    The class TableView is defined in the library called libcanvas. The class PhysicalTable```` is derived from BaseTable, which in turn, is derived from ```BaseGraphicObject. Those three classes are defined in the library called libcore. The signal s_objectModified which is referenced by &PhysicalTable::s_objectModified in connect() is defined in the base class BaseGraphicObject as you can see:

    class BaseGraphicObject: public QObject, public BaseObject {
    	private:
    		Q_OBJECT
    ...
    	signals:
    		//! \brief Signal emitted when the user calls the setModified() method
    		void s_objectModified();
    
    		//! \brief Signal emitted when the user calls the setProtected() method
    		void s_objectProtected(bool);
    ...
    };
    

    After some research, I found that the problem could be the fact that I was not exporting the symbols in the generated DLLs. Strangely I never needed to use this mechanism when using the old signal/slot syntax since the software was working flawlessly on the three platforms. Anyway, I tried to follow the docs about creating and exporting/importing symbols but without success. The code builds fine but I still get the runtime errors.

    Now, I'm out of ideas on how to solve this problem, my software is broken on Windows, and I just wouldn't like to revert the signal/slot connecting syntax because I like the readiness and compile-time checking that the new one provides. :(

    Is there anything else that I can do? I appreciate any help!
    Thanks in advance.

    1 Reply Last reply
    5
    • C Offline
      C Offline
      ChrisW67
      wrote on 17 Nov 2022, 01:02 last edited by ChrisW67
      #2

      If the code is compiling then any new-style connects must be essentially correct because, as you note, the error checking happens at compile time.

      Run time messages of the type you are seeing are more typical of old-style connections. I am assuming there are absolutely no old-style connect() calls present in the modified project, including libraries.

      Have you adorned every public class in the libraries with a MYSHAREDLIB_EXPORT type macro? In this case BaseGraphicObject, BaseTable and TableView.

      Has qmake been run and everything been built from a completely clean state?

      BTW: Thank you for a well constructed query.

      1 Reply Last reply
      4
      • R Offline
        R Offline
        rkhaotix
        wrote on 17 Nov 2022, 02:08 last edited by rkhaotix
        #3

        Hi @ChrisW67 ,

        Thanks for your response. After reading twice the sentence "Have you adorned every public class in the libraries with a MYSHAREDLIB_EXPORT type macro?" I finally found what I was doing wrong!

        I created the macro you mentioned but used the same macro in all classes in all six libraries, which of course is incorrect! So, I created six macros and marked the classes accordingly and now everything is working again!

        Thank you very much! :D

        1 Reply Last reply
        5
        • C Offline
          C Offline
          ChrisW67
          wrote on 17 Nov 2022, 02:18 last edited by
          #4

          I love it when a plan comes together.

          1 Reply Last reply
          3

          1/4

          16 Nov 2022, 23:30

          • Login

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