QT实现记录上一次用户名和密码功能

使用QSettings,该库允许在应用程序中保存和读取配置数据,从而实现在登录时自动填充先前输入的IP和端口。当程序第二次运行时,用户无需再次输入这些信息。
摘要由CSDN通过智能技术生成

说明:在登录时,为了避免每次打开软件都要重新输入账号和密码,可以用QSettings来实现记录功能。

本例子中记录的是ip和port号。

#ifndef PERFORMANCETESTING_H
#define PERFORMANCETESTING_H

#include <QtWidgets/QMainWindow>
#include "ui_performancetesting.h"

class PerformanceTesting : public QMainWindow
{
	Q_OBJECT

public:
	PerformanceTesting(QWidget *parent = 0);
	~PerformanceTesting();

	private slots:
	void PushButton();

	void WriteInit(QString key, QString value);
	void ReadInit(QString key, QString &value);

private:
	Ui::PerformanceTestingClass ui;
};

#endif // PERFORMANCETESTING_H



#include "performancetesting.h"
#include "handlethreadandtest.h"
#include <QDebug>
#include <QMessageBox>
#include <QSettings>
PerformanceTesting::PerformanceTesting(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	QStr
  • 8
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值