1. 使用Qt设计师创建GoToCell对话框。

2. gotocelldialog.cpp

 #include <QRegExp>

 #include "gotocelldialog.h"

 GoToCellDialog::GoToCellDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this); /*初始化窗体*/
/*setupUi()函数会自动将符合on_objectName_signalName()命名惯例的任意槽
与相应的objectName的signalName()信号连接到一起。*/ /*{0,2}中2前面不能有空格,有空格的话,lineEdit框中无法输入*/
QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
/*QRegExpValidator检验器类*/
/*把this传递给QRegExpValidator的构造函数,使它成为GoToCellDialog对象的一个子对象*/
lineEdit->setValidator(new QRegExpValidator(regExp, this)); connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
} /*启用或禁用OK按钮*/
void GoToCellDialog::on_lineEdit_textChanged()
{
/*QLineEdit::hasAcceptableInput()会使用在构造函数中设置的检验器来判断行编辑器中内容的有效性*/
okButton->setEnabled(lineEdit->hasAcceptableInput());
}

3. gotocelldialog.h

 /**/
#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H #include <QDialog> #include "ui_gotocelldialog.h" class GoToCellDialog : public QDialog, public Ui::GoToCellDialog
{
Q_OBJECT public:
GoToCellDialog(QWidget *parent = ); private slots:
void on_lineEdit_textChanged();
}; #endif

4. main.cpp

 #include <QApplication>

 #include "gotocelldialog.h"

 int main(int argc, char *argv[])
{
QApplication app(argc, argv); GoToCellDialog *dialog = new GoToCellDialog;
dialog->show(); return app.exec();
} #if 0 #include <QApplication>
#include <QDialog> #include "ui_gotocelldialog.h" int main(int argc, char *argv[])
{
QApplication app(argc, argv); Ui::GoToCellDialog ui;
QDialog *dialog = new QDialog;
ui.setupUi(dialog);
dialog->show(); return app.exec();
} #endif

C++ GUI Qt4编程(05)-2.2GoToCell的更多相关文章

  1. C++ GUI Qt4编程(10)-3.4spreadsheet

    1. C++ GUI Qt4编程第三章,增加spreadsheet. 2. spreadsheet.h /**/ #ifndef SPREADSHEET_H #define SPREADSHEET_H ...

  2. C++ GUI Qt4编程(09)-3.3spreadsheet-toolbar

    1. C++ GUI Qt4编程第三章,增加工具栏.状态栏和快捷键. 2. mainwindow.h /**/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #i ...

  3. C++ GUI Qt4编程(08)-3.2spreadsheet-resource

    1. C++ GUI Qt4编程第三章,图片使用资源机制法. 2. 步骤: 2-1. 在resource文件夹下,新建images文件,存放图片. 2-2. 新建spreadsheet.qrc文件,并 ...

  4. C++ GUI Qt4编程(07)-3.1menu

    1. C++ GUI Qt4编程第三章,添加menu菜单. 2. mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include < ...

  5. C++ GUI Qt4编程(03)-1.3layout

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:layout.cpp #include <QApplication> #i ...

  6. C++ GUI Qt4编程(02)-1.2quit

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:quit.cpp #include <QApplication> #inc ...

  7. C++ GUI Qt4编程(01)-1.1Hello Qt

    1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7:  Qt版本:5.5.13. 程序:hello.cpp #include <QApplication> #in ...

  8. C++ GUI Qt4编程-创建自定义窗口部件

    C++ GUI Qt4编程-创建自定义窗口部件   Qtqt4 通过Qt窗口部件进行子类化或者直接对QWidget进行子类化,就可以创建自定义窗口部件,下面示范两种方式,并且也会说明如何把自定义窗口部 ...

  9. C++ GUI Qt4 编程 (第二版)

    [加拿大]JasminBlanchette [英]MarkSummerfield . 电子工业 2008. 前几天的问题多是因为版本不兼容的问题. QT本身Q4 Q5就有版本问题,然后集成到VS08 ...

随机推荐

  1. intval()函数

    获取变量的整数值 1.转换前转化后 原因:

  2. c# 二分查找法(2分钟算法)

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  3. Working with WordprocessingML documents (Open XML SDK)

    Last modified: January 13, 2012 Applies to: Office 2013 | Open XML This section provides conceptual ...

  4. Vivado生成edf文件

    https://china.xilinx.com/support/answers/54074.html  综合完成后会跳出个框框,选择open synthesis write_edif module. ...

  5. java IO 管道流PipedOutputStream/PipedInputStream

    详情:管道流的具体实现 import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputS ...

  6. MVC Action控制方式

    1.Controller 的OnActionExecuting中控制 protected override void OnActionExecuting(ActionExecutingContext ...

  7. 转:[python] pip 升级所有的包

    pip 当前内建命令并不支持升级所有已安装的Python模块. 列出当前安装的包: pip list 列出可升级的包: pip list --outdate 升级一个包: pip install -- ...

  8. ASP.NET Session原理及处理方法

    session是怎么存储,提取的 1.在服务器端有一个session池,用来存储每个用户提交session中的数据,Session对于每一个客户端(或者说浏览器实例)是“人手一份”,用户首次与Web服 ...

  9. 一、认识Node.js

    1.什么是Note.js? 简单的说 Node.js 就是运行在服务端的 JavaScript.Node.js 是一个 Javascript 运行环境(runtime).它让 JavaScript 可 ...

  10. Socket 简易静态服务器 WPF MVVM模式(一)

    整体代码下载 主要实现功能: Socket的简单应用 可修改IP和端口 显示来访信息 界面设计: 界面采用MVVM设计,很简陋. 前台的主要目的是 输入IP地址 输入端口 输入文件目录 开启监听和停止 ...