• 9547阅读
  • 1回复

no matching function for call to connect [复制链接]

上一主题 下一主题
离线cao_zhong_yu
 
只看楼主 倒序阅读 楼主  发表于: 2010-05-10
代码:
DialogBox::DialogBox(QWidget *parent) : QWidget(parent)
{
    setupUi(this);
6    QObject::connect(buttonBox->button(QDialogButtonBox::Ok) , SIGNAL(clicked()) , this , SLOT(ensureSlot()) , Qt::QueuedConnection);    
7    QObject::connect(buttonBox->button(QDialogButtonBox::Cancel) , SIGNAL(clicked()) , this , SLOT(cancelSlot()) , Qt::QueuedConnection);
}

在设计器中我定义了一个QDialogButtonBox,有ok 和 cancel两个按键 , 单击触发两个私有槽

报错信息:
dialogbox.cpp: In constructor 'DialogBox::DialogBox(QWidget*)':
dialogbox.cpp:6: error: no matching function for call to 'DialogBox::connect(QPushButton*, const char [11], DialogBox* const, const char [14], Qt::ConnectionType)'
/opt/qte-arm/include/QtCore/qobject.h:197: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/opt/qte-arm/include/QtCore/qobject.h:302: note:                 bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
dialogbox.cpp:7: error: no matching function for call to 'DialogBox::connect(QPushButton*, const char [11], DialogBox* const, const char [14], Qt::ConnectionType)'
/opt/qte-arm/include/QtCore/qobject.h:197: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/opt/qte-arm/include/QtCore/qobject.h:302: note:                 bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const

麻烦知道的朋友指教一二
离线cao_zhong_yu
只看该作者 1楼 发表于: 2010-05-10
具体的原因没有找到
代码改成下面这样就ok了
DialogBox::DialogBox(QWidget *parent) : QWidget(parent)
{
    setupUi(this);
6        connect(buttonBox , SIGNAL(accepted()) , this , SLOT(ensureSlot()));    
7    connect(buttonBox , SIGNAL(rejected()) , this , SLOT(cancelSlot()));
}
默认情况下,标准的QDialogButtonBox::Ok按钮具有AcceptRole属性,QDialogButtonBox::Cancel具有RejectRole属性
AcceptRole属性的按钮具有accepted()信号,RejectRole属性的按钮具有rejected()信号

QDialogButtonBox里有void QDialogButtonBox::clicked ( QAbstractButton * button )   [signal] 信号,扩展更多的按钮也不会有上面的问题
快速回复
限100 字节
 
上一个 下一个