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 ...
随机推荐
- Python基础入门-集合
今天给大家分享的是python中集合(set)的概念,集合这个词其实和高中学的数学集合的概念很相近,或者作为初学者你就可以把它理解为数学当中的集合.在python中集合(set)是由一个个键组成的,但 ...
- oracle数据库单表查询
今天给大家分享的是关于数据库的单表查询,像单表查询/多表查询/分组查询/子查询,这些方法的使用在实际项目过程中会经常用到,作为一名合格的测试人员如果不会数据库那肯定是不行的,行走江湖可能随时会面临被侮 ...
- HTTP Debugger Pro安装教程
相关链接:HTTP Debugger Pro使用教程 安装步骤: 1.解压压缩包 2.双击运行安装文件 3.根据向导提示点击Next 4.选择接受协议,点击Next 5.选择高级模 ...
- XE改变图标颜色
放一个image,load 一张png/..图片 再放一个FillRGBEffect, 将此控价拖到image下 改变FillRGBEffect的Color,就改变了image图标上的颜色. 原图为黑 ...
- Math对象的使用
1. Math.floor() === 向下取整 2.Math.random() === 取一个浮点随机数 3.Math.round() === 四舍五入后一个最接近的整数 4.Math.ceil() ...
- 利用find同时查找多种类型文件
find . -name "*.c" -o -name "*.cpp" -o -name "*.h" 就可以列出当前目录下面所有的c,cpp ...
- ecliplse导入tomcat
上面点击之后,弹出的窗口最大化: 导入成功之后如下图:
- 转:Linux下同时启动两个Tomcat进行设置
转: Linux下同时启动两个Tomcat进行设置 解压tar.gz:tar -zxvf apache-tomcat-6.0.41.tar.gz 至相应的路径下,可解压至两个不同的路径或者相同的路径下 ...
- C# 接口(3)
这么半天说了如何使用,实现接口.相信也都发现了接口和抽象类很多相似的地方. 但是! 这两个根本就是不一样的. 抽象类 : ...
- kafka启动报错Cannot allocate memory;There is insufficient memory for the Java Runtime Environment to continue.
kafka启动过程报错,配置没有问题,这就懵了!! Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000 ...