C++ GUI Qt4编程(05)-2.2GoToCell
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的更多相关文章
- C++ GUI Qt4编程(10)-3.4spreadsheet
1. C++ GUI Qt4编程第三章,增加spreadsheet. 2. spreadsheet.h /**/ #ifndef SPREADSHEET_H #define SPREADSHEET_H ...
- C++ GUI Qt4编程(09)-3.3spreadsheet-toolbar
1. C++ GUI Qt4编程第三章,增加工具栏.状态栏和快捷键. 2. mainwindow.h /**/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #i ...
- C++ GUI Qt4编程(08)-3.2spreadsheet-resource
1. C++ GUI Qt4编程第三章,图片使用资源机制法. 2. 步骤: 2-1. 在resource文件夹下,新建images文件,存放图片. 2-2. 新建spreadsheet.qrc文件,并 ...
- C++ GUI Qt4编程(07)-3.1menu
1. C++ GUI Qt4编程第三章,添加menu菜单. 2. mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include < ...
- C++ GUI Qt4编程(03)-1.3layout
1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7: Qt版本:5.5.13. 程序:layout.cpp #include <QApplication> #i ...
- C++ GUI Qt4编程(02)-1.2quit
1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7: Qt版本:5.5.13. 程序:quit.cpp #include <QApplication> #inc ...
- C++ GUI Qt4编程(01)-1.1Hello Qt
1. 根据C++ GUI Qt4编程(第二版)整理2. 系统:centos7: Qt版本:5.5.13. 程序:hello.cpp #include <QApplication> #in ...
- C++ GUI Qt4编程-创建自定义窗口部件
C++ GUI Qt4编程-创建自定义窗口部件 Qtqt4 通过Qt窗口部件进行子类化或者直接对QWidget进行子类化,就可以创建自定义窗口部件,下面示范两种方式,并且也会说明如何把自定义窗口部 ...
- C++ GUI Qt4 编程 (第二版)
[加拿大]JasminBlanchette [英]MarkSummerfield . 电子工业 2008. 前几天的问题多是因为版本不兼容的问题. QT本身Q4 Q5就有版本问题,然后集成到VS08 ...
随机推荐
- 利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。
首先利用 Nuget 获取 Aspose.Words.dll public ActionResult AsposeWordsDemo() { string srcFileName = Server.M ...
- Install zlib/libpng/jpeg/freetype/libgd/GD on Mavericks即mac10.9(转)
转自:http://wangqinhu.com/install-gd-on-mavericks/ Various applications depend on library GD, however, ...
- ASP.NET MVC5 Authentication Filters执行链
注意区分认证和授权: The following are the differences in short: Authentication(认证): It is a process of verif ...
- 正确理解WPF中的TemplatedParent (转贴)
http://blog.csdn.net/idebian/article/details/8761388 (注:Logical Tree中文称为逻辑树,Visual Tree中文称为可视化树或者视觉树 ...
- HTML5和CSS3实例教程 中文版 高清PDF扫描版
HTML5和CSS3实例教程共分3部分,集中讨论了HTML5和CSS3规范及其技术的使用方法.首先是规范概述,介绍了新的结构化标签.表单域及其功能(包括自动聚焦功能和占位文本)和CSS3的新选择器.接 ...
- 用ActionBar的ActionProvider的时候报错:cannot be cast to android.view.ActionProvider
在用ActionBar的自定义ActionProvider的时候有时候会遇到以下的报错:
- asp.net winform 界面传值
第一种 //form1 //静态传值 public static string Chuanzhi; string Chuanzhi = textbox.text; //form2 string Chu ...
- asp.net mvc 请求处理流程,记录一下。
asp.net mvc 请求处理流程,记录一下.
- springMVC 学习笔记(一):springMVC 入门
springMVC 学习笔记(一):spring 入门 什么是 springMVC springMVC 是 spring 框架的一个模块,springMVC 和 spring 无需通过中间整合层进行整 ...
- linux防火墙(二)—— iptables语法之选项和控制类型
一.语法: iptables [-t 表名] 选项 [链名] [匹配条件] [-j 控制类型] 未指定表名时,默认用filter表:链名,控制类型要大写:除非设置默认策略,否则必须指定匹配条件:不指定 ...