使用信号和插槽连接后,应触发搜索然后显示其他类的信息的类:
#include "recruitsearch.h"
#include "ui_recruitsearch.h"
#include <cctype>
#include <QtGui>
#include <string>
#include <QtCore>
using namespace std;
RecruitSearch::RecruitSearch(QWidget *parent) :
QDialog(parent),
ui(new Ui::RecruitSearch)
{
ui->setupUi(this);
}
RecruitSearch::~RecruitSearch()
{
delete ui;
}
void RecruitSearch::on_pushButton_clicked()
{
//if(EmployerSearch::ui->buttonBox->clicked();
if(ui->rfrId->text().isEmpty() || ui->rfrId->text().isNull() || (is_Digit(ui->rfrId->text().toStdString())==false) ){
QMessageBox::warning(this,"Error", "Please enter a valid RFR id(digits only)");
}
else{
accepted();
this->close();
}
}
int RecruitSearch:: getRfrId(){
return ui->rfrId->text().toInt();
}
bool RecruitSearch::is_Digit( string input){
for (int i = 0; i < input.length(); i++) {
if (!std::isdigit(input[i]))
return false;
}
return true;
}
用显示器上课。我将如何连接这两个插槽并使用第一种形式的 id 来搜索链表,然后使用另一种形式显示结果:
#include "rfrform.h"
#include "ui_rfrform.h"
#include <cctype>
#include <string>
#include <QString>
#include <QtGui>
#include <QtCore>
#include <iostream>
using namespace std;
RfrForm::RfrForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::RfrForm)
{
ui->setupUi(this);
}
RfrForm::~RfrForm()
{
delete ui;
}
void RfrForm::setEmpName(string name){
QString qstr=QString::fromStdString(name);
ui->EmployerName->setText(qstr);
}
void RfrForm::setAOE(string aoe){
QString qstr=QString::fromStdString(aoe);
ui->AOE->setText(qstr);
}
void RfrForm::setEmpId(int id){
QString qstr=QString::number(id);
ui->EmpId->setText(qstr);
}// end of setId
void RfrForm::setNumOfPos(int num){
QString qstr=QString::number(num);
ui->numOfPos->setText(qstr);
}
void RfrForm::setGender(string gen){
QString qstr=QString::fromStdString(gen);
ui->gender->setText(qstr);
}
void RfrForm::setMaxRecruits(int max){
QString qstr=QString::number(max);
ui->MaxRecruits->setText(qstr);
}
void RfrForm::display(RFR *temp){
this->show();
}