c++ connect函数失败,因为信号找不到对象[已关闭]

wr98u20j  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(113)

**已关闭。**此问题需要debugging details。目前不接受回答。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答问题。
5天前关闭。
这篇文章是编辑并提交审查3天前.
Improve this question
当调用QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type = Qt::AutoConnection)时,我得到错误“不能调用没有对象的成员函数 *"。
我尝试将自定义按钮发出的信号连接到按钮的容器类中定义的slot。在容器中我定义:

signals:
        void hovered();

字符串
在容器头中,我定义了一个customButton类的对象:

customButton* casilla = new customButton;


和插槽一样:

public slots:
        void mostrarCasilla();


现在,在容器构造函数中,我尝试用这行连接信号和插槽

QObject::connect(casilla,&customButton::hovered(),this,&board::mostrarCasilla());


我认为是某种简单的错误,我会把完整的代码,给予一个例子,为社会,如果我使它的工作

hsgswve4

hsgswve41#

&A::func是成员函数指针,&的作用是获取func的地址。
对于func()()是一个函数调用,也许你可以在func()之后得到一个值,但这个值是r值,&需要一个l值,所以&A::func()在任何情况下都是错误的。

相关问题