快速设计对话框-qt designer-vs2008

#ifndef GOTODIALOG_H
#define GOTODIALOG_H

#include <QtGui>
#include "ui_gotodialog.h"

class gotodialog : public QDialog, public Ui::GoToCellDialog
{
	Q_OBJECT

public:
	gotodialog(QWidget *parent = 0, Qt::WFlags flags = 0);
	~gotodialog();

private:
	// 命名符合 on_objectName_signalName(),
	// setupUi会自动建立connect(lineEdit,SIGNAL(textChanged(const QString &)), this, SLOT(on_lineEdit_textChanged()));
	void on_lineEdit_textChanged();
};

#endif // GOTODIALOG_H

#include "gotodialog.h"

gotodialog::gotodialog(QWidget *parent, Qt::WFlags flags)
	: QDialog(parent, flags)
{
	// 初始化窗体
	setupUi(this); 

	// 检验器,控制输入:允许一个大写或小写字母,
	// 后面跟一个范围是1~9的数字,后面再跟0个、1个或2个0~9的数字
	QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
	lineEdit->setValidator(new QRegExpValidator(regExp, this));

	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}

gotodialog::~gotodialog()
{

}


void gotodialog::on_lineEdit_textChanged()
{
	okButton->setEnabled(lineEdit->hasAcceptableInput());
}

#include "gotodialog.h"
#include <QtGui/QApplication>
#include  <QtGui/QDialog> 
#include "ui_gotodialog.h" 

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	gotodialog *dialog = new gotodialog;
	dialog->show();
	return a.exec();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值