先用designer做了一个ui,然后生成了ui.h,然后分别手动添加了.cpp 和.h,make,测试自定义槽显示msgbox,可以实现,现在想要实现一些算法,也就是添加一般的函数,该怎么添加呢,可以把c写的算法直接添加进来么,我是新手,请前辈指导~谢谢~
#include <QMessageBox>
#include "MyDlg.h"
MyDlg::MyDlg()
{
ui.setupUi(this);
QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(close()));
QObject::connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(show()));
QObject::connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(openio()));
QObject::connect(ui.pushButton_4, SIGNAL(clicked()), this, SLOT(start(int)));
QObject::connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(stop()));
}
//自定义槽
void MyDlg::show()
{
QMessageBox::information(this, tr("Hello"), tr("Hello World"), tr("OK"));
}
void MyDlg::openio()
{
QMessageBox::information(this, tr("Hello"), tr("Open IO"), tr("OK"));
}
void MyDlg::start(int value) //解算,此处为算法槽
{
Functionforstart(value) // test:return "0" in Text Browser
}
void MyDlg::stop()
{
QMessageBox::information(this, tr("Hello"), tr("Stop"), tr("OK"));
}