gpt4 book ai didi

c++ qt QObject::connect: 没有这样的插槽

转载 作者:行者123 更新时间:2023-11-30 00:36:23 26 4
gpt4 key购买 nike

我已经这样定义了我的插槽:

void choixPoints:: prendpixel1(Pixel depart)
{
//...
}

我想执行下面的句子:

Pixel depart= picmou->define(); //definition of a pixel, well defined 
connect(chp3, SIGNAL(clicked()), this, SLOT(prendpixel1(Pixel depart)));

然而,当我执行时,我得到:

QObject::connect: No such slot choixPoints::prendpixel1(Pixel depart)

为什么我的插槽不起作用?

最佳答案

我认为问题在于您在 SLOT 定义中放入了一个变量名称“depart”,这是不正确的。 SLOT 和 SIGNAL 定义必须只有函数名称和类型。所以:

connect(chp3, SIGNAL(clicked()), this, SLOT(prendpixel1(Pixel)));

顺便说一句,我认为它也是空间敏感的,所以 SLOT(anotherfn(Pixel, Pixel)) 也是错误的。

HTH,露丝

关于c++ qt QObject::connect: 没有这样的插槽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16085611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com