#include "socketobject.h"#include "Registered.h"#include <QMessageBox>#include "MyMessage.h"#include <QMessageBox>#include "GBK.h"#include <QIcon>#include <QApplication>#include <QMessageBox>#include <QCloseEvent>SocketObject::SocketObject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags){ui.setupUi(this);//设置托盘图标文字system.setToolTip("Hello Wellcome");//设置图标system.setIcon(QIcon(":/SocketObject/Resources/QQIcon.ico"));//设置菜单QMenu *menu=new QMenu();menu->addAction(ui.actionExit);menu->addSeparator();menu->addAction(ui.actionHelp);system.setContextMenu(menu);//显示托盘菜单system.show();//关联托盘事件connect(&system,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSystemTrayIcon(QSystemTrayIcon::ActivationReason)));connect(ui.actionExit,SIGNAL(triggered()),this,SLOT(OnExit()));//点击显示菜单connect(ui.actionHelp,SIGNAL(triggered()),this,SLOT(OnHelp()));connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(OnBtn1()));connect(ui.pushButton_2,SIGNAL(clicked()),this,SLOT(OnBtn2()));//读取文件char ch1[32];char ch2[32];FILE* fp1=fopen("刘俊良1.text","ab+");FILE* fp2=fopen("刘俊良2.text","ab+");if (fread(ch1,1,32,fp1)!=0){}else{//没有读到文件是,不做其他处理QMessageBox::information(this,"HELLO","文件夹中没有内容");}if (fread(ch2,1,32,fp2)!=0){}else{QMessageBox::information(this,"HELLO","not file");//没有读到文件是,不做其他处理}fclose(fp1);//关闭文件fclose(fp2);//转化为Q风格字符串QString str1=GBK::ToUnicode(ch1);QString str2=GBK::ToUnicode(ch2);this->account=str1;this->password=str2;}SocketObject::~SocketObject(){}int SocketObject::OnSystemTrayIcon(QSystemTrayIcon::ActivationReason reason){if (reason==QSystemTrayIcon::DoubleClick||reason==QSystemTrayIcon::Trigger){//显示该窗口this->showNormal();}return 0;}int SocketObject::OnExit(){QApplication::exit(0);return 0;}int SocketObject::OnHelp(){QMessageBox::information(this,"HELP","Wellcome");return 0;}int SocketObject::OnBtn1(){if (ui.lineEdit->text()==account&&ui.lineEdit_2->text()==password){MyMessage message(this);message.exec();}else{QMessageBox::information(this,"error",GBK::ToUnicode("账号或密码错误"));}return 0;}int SocketObject::OnBtn2(){Registered reg(this);reg.exec();return 0;}void SocketObject::closeEvent(QCloseEvent *event)//重置关闭窗口{this->hide();event->ignore();}QString SocketObject::account="0154132";//静态成员 实现共享数据QString SocketObject::password="123";
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。