|
定义头文件
[code:1]#ifndef MAINVIEW_H
#define MAINVIEW_H
#include <mainui.h>
class mainView : public mainui
{
public:
mainView(QWidget *parent=0);
~mainView();
void lookForHost(char hostName[]);
public slots:
virtual void slotStartClicked();
};
#endif[/code:1]
cpp文件
[code:1]
#include "mainview.h"
#include "qmessagebox.h"
#include "qpushbutton.h"
mainView::mainView(QWidget *parent) : mainui(parent)
{
connect(pushButton1, SIGNAL(clicked()), this, SLOT(slotStartClicked()) );
connect(pushButton2, SIGNAL(clicked()), this, SLOT(slotStartClicked()));
slotStartClicked();
}
mainView::~mainView()
{
}
void mainView::slotStartClicked()
{
QMessageBox::warning(this, "Warning", "Just test");
}
[/code:1]
编译正确,运行时错误提示:
QObject::connect: No such slot mainui::slotStartClicked()
QObject::connect: (sender name: 'pushButton1')
QObject::connect: (receiver name: 'Form1')
this指针怎么会指到父类mainui去啊 |
|