24,855
社区成员
发帖
与我相关
我的任务
分享
//logindlg.h
#ifndef SIGNINDLG_H
#define SIGNINDLG_H
#include <QDialog>
#include<QMessageBox>
#include<QString>
#include<QPushButton>
#include"ui_signindlg.h"
using namespace std;
namespace Ui {
class SignInDlg;
}
class SignInDlg : public QDialog, public Ui::SignInDlg
{
Q_OBJECT
public:
explicit SignInDlg(QWidget *parent = 0);
~SignInDlg();
void check();
private:
Ui::SignInDlg *ui;
};
#endif // SIGNINDLG_H
//logindlg.cpp
#include "signindlg.h"
#include "ui_signindlg.h"
SignInDlg::SignInDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::SignInDlg)
{
ui->setupUi(this);
//此处发生错误
QObject::connect(pushButton, &QPushButton::clicked, this, &SignInDlg::check);
check();
}
void SignInDlg::check()
{
QString username;
QString password;
username = ui->usernameLineEdit->text();
if (username.length() > 16)
{
QMessageBox msgBox;
msgBox.setText("Username cannot be longer than 16 chars!");
msgBox.setStandardButtons(QMessageBox::Yes);
msgBox.setDefaultButton(QMessageBox::Yes);
}
}
SignInDlg::~SignInDlg()
{
delete ui;
}