paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework
BSD 3-Clause "New" or "Revised" License
2.92k stars 794 forks source link

Get Warning "qt.core.qobject.connect: QObject::connect: signal not found in NodeDelegateModel" while using load *.dll method. #419

Open sirius-william opened 2 months ago

sirius-william commented 2 months ago

I make a node plugin to extend my application. User can develop their own Node by inheriting 'NodeDelegateModel' class and compile it as SHARED library (.dll). The application will load .dll at the runtime and do the following code to connect signals: `std::unique_ptr new_node = construct_func();

    id = newNodeId();

    connect(new_node.get(),
            &NodeDelegateModel::dataUpdated,
            [id, this](PortIndex const portIndex) {
                std::cout << "data_update" << std::endl;
                std::unordered_set<ConnectionId> const &connected = connections(id,
                                                                                PortType::Out,
                                                                                portIndex);
                QVariant const portDataToPropagate = portData(id, PortType::Out, portIndex, PortRole::Data);
                for (auto const &cn: connected) {
                    setPortData(cn.inNodeId, PortType::In, cn.inPortIndex, portDataToPropagate, PortRole::Data);
                }
            });
    connect(new_node.get(),
            &NodeDelegateModel::portsAboutToBeDeleted,
            this,
            [id, this](PortType const portType, PortIndex const first, PortIndex const last) {
                portsAboutToBeDeleted(id, portType, first, last);
            });

    connect(new_node.get(),
            &NodeDelegateModel::portsDeleted,
            this,
            &NodeGraphicsModel::portsDeleted);

    connect(new_node.get(),
            &NodeDelegateModel::portsAboutToBeInserted,
            this,
            [id, this](PortType const portType, PortIndex const first, PortIndex const last) {
                portsAboutToBeInserted(id, portType, first, last);
            });

    connect(new_node.get(),
            &NodeDelegateModel::portsInserted,
            this,
            &NodeGraphicsModel::portsInserted);`

.dll can load correctly. But after calling 'addNode' or after doing others (maybe not after addNode), I got warning "qt.core.qobject.connect: QObject::connect: signal not found in NodeDelegateModel" 5 times. The node can add into Scene but can not put in right position. I think the signals above are not connected correctly. But why? What should I do while developing the the using loading dll.

sirius-william commented 2 months ago

My *.dll project is compiled using following header file: `class Q_DECL_EXPORT NODE_EDITOR_PUBLIC ValueNode : public NodeDelegateModel {

Q_OBJECT

public:
    QString caption() const override;

    QString name() const override;

    unsigned int nPorts(QtNodes::PortType portType) const override;

    NodeDataType dataType(QtNodes::PortType portType, PortIndex portIndex) const override;

    void setInData(std::shared_ptr<NodeData> nodeData, PortIndex const portIndex) override;

    std::shared_ptr<NodeData> outData(const PortIndex port) override;

    QWidget *embeddedWidget() override;

private:
    QLineEdit *edit;
};`
nolankramer commented 1 month ago

Plugins (shared libraries), typically are developed with __declspec(dllimport) as the class attribute - as their headers are never compiled against, so it is assumed their symbols are always imported by the linking program.