QT自定义控件-经纬度输入框

原文

CoordinateEdit.h

#pragma once

#include <QWidget>
#include <QEvent>
class QLineEdit;
class QLabel;
class CoordinateEdit : public QWidget
{
   
	Q_OBJECT
public:
	enum Type
	{
   
		Type_Longitude,
		Type_Lagitude
	};
	CoordinateEdit(Type type = Type_Longitude,QWidget *parent = 0);
	~CoordinateEdit();
	void SetType(Type type){
    m_type = type; }
	QString GetCoordinate() {
    return m_coordinate; }
	QString GetDegree() {
    return m_d; }
	QString GetMinute() {
    return m_m; }
	QString GetSecond() {
    return m_s + "." + m_ms; }
protected:
	bool eventFilter(QObject *watched, QEvent *event);
signals:
	void coordChange(const QString &);
private slots:
	void OnLineEdit(const QString& text);
private:
	Type m_type;
	QLineEdit* m_degree;
	QLineEdit* m_minute;
	QLineEdit* m_second;
	QLineEdit* m_msec;
	QLabel* m_dLab;
	QLabel* m_mLab;
	QLabel* m_sLab;
	QString m_coordinate;
	QString m_d;
	QString m_m;
	QString m_s;
	QString m_ms;
};

CoordinateEdit.cpp

#include "CoordinateEdit.h"
#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QRegExp>
#include <QRegExpValidator>
#include <QKeyEvent>
CoordinateEdit::CoordinateEdit(Type type,QWidget *parent)
	: QWidget(parent)
	, m_type(type)
{
   
	if (parent)
	{
   
		parent->setLayout(new QHBoxLayout
  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在于GIS相关的软件中经常要输入经纬度数值,而基于MFC Edit控件的经纬度输入控件需 要创建三个Edit编辑框,来分别输入度、分、秒数值,并且需要分别进行输入范围和有效 性的检验。该基于BCGControlBar的经纬度输入控件实现了在一个输入窗口中分别按照度 、分、秒三个值域来输入经纬度数值,并同时进行了输入分有效性和输入范围的检验。经 纬度中的度、分、秒字段均通过数字键盘直接输入数值,也可通过微调按钮或者键盘的上 下键进行数字的增减,你可以通过左右键进行度、分、秒输入域的切换。该控件可以设置 度的输入范围,默认的度范围是0~89。该1.1版本修复了键盘直接输入数值的逻辑问题。 In the GIS-related software often have to enter the latitude and longitude values, and MFC Edit control based on the latitude and longitude input controls need to create three Edit edit box to enter the degrees, minutes and seconds values, and the need for input range and validity of the test. The BCGControlBar-based latitude and longitude input control realizes the input of the latitude and longitude values in degrees,minutes,and seconds in one input window, and simultaneously verifies the validity of the input points and the input range.The degrees, minutes, and seconds fields can be entered directly through the numeric keypad, also can be fine-tuning button or the keyboard up and down keys to increase or decrease the number, you can use left and right keys for degrees, minutes and seconds to switch the input field. The control can set the input range of degree, the default range is 0 ~ 89.The 1.1 version fixes the logic of keyboard input values directly.
Qt自定义控件大全Designer源码是一个包含了多种自定义控件的全套源码,它主要用于在Qt设计师中使用。Qt是一个跨平台的C++应用程序开发框架,提供了丰富的图形界面控件,但有时候我们可能需要自定义一些特殊的控件来满足我们的需求。 Qt自定义控件大全Designer源码包含了很多常用的自定义控件,如自定义按钮、进度条、滑块、验证码输入框等等。这些控件的设计和实现已经封装好,我们只需要将源码添加到我们的项目中,然后在Qt设计师中直接使用即可。 使用Qt自定义控件大全Designer源码有以下几个优点: 1.提供了丰富的自定义控件选择:Qt自定义控件大全Designer源码包含了多样化的控件,可以满足不同项目的需求。无论是一些简单的控件,还是一些复杂的控件,我们都可以找到合适的选择。 2.减少开发时间和工作量:使用源码中的自定义控件可以减少我们从头开始设计和实现的工作,节省了大量的开发时间和工作量。我们只需要将源码添加到项目中并正确配置,就可以直接在设计师中使用这些自定义控件。 3.提高应用程序的美观性和用户体验:Qt自定义控件大全Designer源码中的控件经过精心设计和实现,具有良好的界面效果和用户交互体验。使用这些自定义控件可以为我们的应用程序提供更加美观和友好的界面。 总之,Qt自定义控件大全Designer源码是一个提供了多种自定义控件的全套源码,使用它可以快速、方便地实现各种自定义控件,提高应用程序的开发效率和用户体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值