当前位置: 首页 > news >正文

通过QT制作一个模仿微信主界面的界面(不要求实现具体通信功能)

main.cpp

#include "widget.h"
#include "second.h"#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.show();//实例化第二个界面Second s;QObject::connect(&w, &Widget::my_jump, &s, &Second::jump_slot);return a.exec();
}

second.cpp

#include "second.h"
#include "ui_second.h"Second::Second(QWidget *parent) :QWidget(parent),ui(new Ui::Second)
{ui->setupUi(this);
}Second::~Second()
{delete ui;
}//第二个界面自定义的槽函数的实现
void Second::jump_slot()
{this->show();
}void Second::on_sendBtn_clicked()
{QString msg = ui->msgEdit->text();ui->msgWidget->addItem(msg);
}

widget.cpp

#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);ui->setupUi(this);this->setWindowFlag(Qt::FramelessWindowHint);this->setAttribute(Qt::WA_TranslucentBackground);connect(ui->exit_btn, &QPushButton::clicked, this, &Widget::on_exit_btn_clicked);connect(ui->login_btn, &QPushButton::clicked, this, &Widget::on_login_btn_clicked);}Widget::~Widget()
{delete ui;
}void Widget::on_login_btn_clicked()
{if(ui->name_edit->text() == "admin" && ui->code_edit->text() == "123456"){QMessageBox::information(this,"提示","登录成功",QMessageBox::Ok);this->close();emit my_jump();}else{QMessageBox msg(QMessageBox::Warning,"警告","账号和密码不匹配,是否重新登陆",QMessageBox::Yes | QMessageBox::No,this);int ret = msg.exec();if(ret == QMessageBox::Yes){  //判断警报this->show();ui->code_edit->clear();   //清除}else{this->close();   //关闭}}
}void Widget::on_exit_btn_clicked()
{this->close();
}

second.ui

widget.ui

http://www.lryc.cn/news/301109.html

相关文章:

  • 作物模型狂奔:WOFOST(PCSE) 数据同化思路
  • 腾讯云4核8G服务器能支持多少人访问?
  • 多重背包问题 ⅠⅡ Ⅲ
  • 挑战杯 python的搜索引擎系统设计与实现
  • 【LeetCode: 103. 二叉树的锯齿形层序遍历 + BFS】
  • C#学习(十三)——多线程与异步
  • MySQL 数据库安装教程详解(linux系统和windows系统)
  • 从汇编分析C语言可变参数的原理,并实现一个简单的sprintf函数
  • Word docx文件重命名为zip文件,解压后直接查看和编辑
  • SpringBoot中公共字段的自动填充
  • 【天衍系列 03】深入理解Flink的Watermark:实时流处理的时间概念与乱序处理
  • day07.C++类与对象
  • String讲解
  • 人群异常聚集监测系统-聚众行为检测与识别算法---豌豆云
  • 多模态基础---BERT
  • 图表示学习 Graph Representation Learning chapter2 背景知识和传统方法
  • OpenMVG(计算两个球形图像之间的相对姿态、细化重建效果)
  • 【QT+QGIS跨平台编译】之三十四:【Pixman+Qt跨平台编译】(一套代码、一套框架,跨平台编译)
  • 2.17学习总结
  • Unity类银河恶魔城学习记录7-7 P73 Setting sword type源代码
  • 安卓版本与鸿蒙不再兼容,鸿蒙开发工程师招疯抢
  • 《白话C++》第9章 泛型,Page842~844 9.4.2 AutoPtr
  • 服务流控(Sentinel)
  • 点亮代码之灯,程序员的夜与电脑
  • ClickHouse--07--Integration 系列表引擎
  • 前端架构: 脚手架框架之yargs的11种基础核心特性的应用教程
  • MySQL性能调优篇(6)-主从复制的配置与管理
  • Linux第49步_移植ST公司的linux内核第1步_获取linux源码
  • 怎样学习Windows下命令行编写
  • 数据结构第十六天(二叉树层序遍历/广度优先搜索(BFS)/队列使用)