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 ...
随机推荐
- Django框架 之 跨域请求伪造
Django框架 之 跨域请求伪造 浏览目录 同源策略与Jsonp 同源策略 Jsonp jQuery对JSONP的实现 CORS 简介 两种请求 同源策略与Jsonp 同源策略 同源策略(Same ...
- c++模板实现 linq
// ConsoleApplication32.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" using namespace std; # ...
- mvc json 日期问题的最简单解决方法
1.首先编写BaseController这个类,需要引入Newtonsoft.Json.dll程序集 using System;using System.Collections.Generic;usi ...
- html5操作类名API——classlist
tagNode.classList.add('123'); // 添加类 tagNode.classList.remove('bbb'); // 删除类 tagNode.classList.toggl ...
- LightOJ 1282 Leading and Trailing (数学)
题意:求 n^k 的前三位和后三位. 析:后三位,很简单就是快速幂,然后取模1000,注意要补0不全的话,对于前三位,先取10的对数,然后整数部分就是10000....,不用要,只要小数部分就好,然后 ...
- 【实习项目记录】(二) JSON
介绍 JSON JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式. 易于人阅读和编写.同时也易于机器解析和生成. 它基于JavaScript Program ...
- C# 类型初始化(Type initialization)
这些天突然看到一些大虾门写的有关类型初始化的文章.那种感觉真叫跌宕起伏啊. 博文地址如下,自己慢慢体会吧! 起步:http://www.cnblogs.com/artech/archive/2008/ ...
- 《Andorid开源》greenDao 数据库orm框架
一 前言:以前没用框架写Andorid的Sqlite的时候就是用SQLiteDatabase ,SQLiteOpenHelper ,SQL语句等一些东西,特别在写SQL语句来进行 数据库操作的时 ...
- 求整数数组(长度为n),出现大于2/n次数的数字
条件:时间复杂度是O(n),空间复杂度是O(1) 方法1:标记法 , , , , , , , , , , , , , }; int len = arr.Length; int[] c = new in ...
- asp.netcore+jenkins+docker+svn+centos7.2 持续集成,每天凌晨获取最新代码打包发布
运行环境: centos7.2服务器或则虚拟机 可以是腾讯云也可以是内网服务器,(如果是内网服务器需要用frp做内网穿透,这样才可以通过外网访问该服务器) svnserver 来托管代码 一.安装je ...