代码:
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
麻烦知道的朋友指教一二