[24章]Qt 全流程实战企业级项目 - 云对象存储浏览器

赵颜
• 阅读 142

学习地址1:https://pan.baidu.com/s/1OeNVv-9zowTbFVIpjSl8aQ 提取码:86h5 学习地址2:https://pan.baidu.com/s/187GgonRED21EseHMNE5ayg 提取码:bwsj

今天给大家讲解关于Qt的内容,我会在文章里面带着大家从0到1为你系统构建Qt知识体系,然后全流程实战开发项目“云对象存储浏览器”,让大家少走弯路,更快速的掌握Qt技术。

那么我们先来认识一下,什么是QT,他的具体作用是什么,应用在哪些方面? Qt是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架。它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器。 QT之所以能够在全世界范围内得到广大软件开发者的青睐和使用,一个很大的原因是QT入门确实是非常容易。很少的代码就能折腾出一个比较复杂的软件界面。 QT已经支持传统模式下的软件界面开发技术体系以及新模式下的软件界面开发技术体系。传统模式比如QT Widgets,这种模式下的竞争对手比如MFC早就“躺平”了表示不再升级更新了。

接下来,我们开始代码实战,编写mainwindows.cpp

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this);

//一般在qt的构造函数中进行初始化操作
//显示当前窗口的时候,显示另外一个窗口TestWidget

#if 1 //创建窗口对象,没有给W对象指定父对象 //要显示这个窗口必须要进行show()操作 TestWidget* w = new TestWidget; w->show(); #else // 创建窗口对象,给W对象指定父对象 // explicit TestWidget(QWidget parent = nullptr); // 如果创建一个窗口对象的时候给其指定了父对象,这个窗口就不是一个独立窗口 // 这样的话当前父窗口显示的时候,子窗口就一并被显示出来了 // 这时候子窗口是没有边框的 TestWidget w = new TestWidget(this); #endif

//创建对话框窗口
Dialog *dlg = new Dialog();
//非模态
dlg->show();

}

#include "mainwindow.h" #include "ui_mainwindow.h" #include "testwidget.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this);

//一般在qt的构造函数中进行初始化操作
//显示当前窗口的时候,显示另外一个窗口TestWidget
//创建窗口对象,没有给W对象指定父对象
TestWidget* w = new TestWidget;
w->show();

}

MainWindow::~MainWindow() { delete ui; } 获取类的属性 const QMetaObject *metaobject = object->metaObject(); int count = metaobject->propertyCount(); for (int i = 0; i < count; ++i) { QMetaProperty metaproperty = metaobject->property(i); const char *name = metaproperty.name(); QVariant value = object->property(name); qDebug() << name << value; } 在common中引入的坐标依赖 org.apache.commons commons-lang3

com.fasterxml.jackson.core jackson-core com.fasterxml.jackson.core jackson-annotations com.fasterxml.jackson.core jackson-databind com.fasterxml.jackson.datatype jackson-datatype-jsr310

迭代查询代码,一级缓存与二级缓存结合: @GetMapping("query") public Object query(String id) {

String articleKey = "article:" + id;
String articleKeyRedis = "REDIS_ARTICLE:" + id;

Article article = cache.get(articleKey, s -> {
    System.out.println("文章id为"+id+"的没有查询到,则从Redis中查询后返回...");

    Article articleReal = null;
    String articleJsonStr = redis.get(articleKeyRedis);
    // 判断从redis中查询到的文章数据是否为空
    if (StringUtils.isBlank(articleJsonStr)) {
        System.out.println("Redis中不存在该文章,将从数据库中查询...");

        // 如果为空,则进入本条件,则从数据库中查询数据
        articleReal = articleService.queryArticleDetail(id);
        // 手动把文章数据设置到redis中,后续再次查询则有值
        String articleJson = JsonUtils.objectToJson(articleReal);
        redis.set(articleKeyRedis, articleJson);
    } else {
        System.out.println("Redis中存在该文章,将直接返回...");

        // 如果不为空,则直接转换json类型article再返回即可
        articleReal = JsonUtils.jsonToPojo(articleJsonStr, Article.class);
    }
    return articleReal;
});

return article;

} @Resource private IArticleTypeService articleTypeService;

@Resource private Cache<String, List> articleTypeCache;

@Resource private RedisOperator redis;

@Override public void run(String... args) throws Exception { System.out.println("缓存预热。。。");

// 1. 查询所有分类数据
List<ArticleType> types = articleTypeService.list();
System.out.println(types);

String articleTypeKey = "articleTypeList";

// 2. 设置分类数据到本地缓存
articleTypeCache.put(articleTypeKey, types);

// 3. 设置分类数据到redis
redis.set(articleTypeKey, JsonUtils.objectToJson(types));

} 修改hostname,可以区分每个tab是哪台虚拟机 -- 获得http的协议版本号 -- ngx.say("http协议版本: " .. ngx.req.http_version());

-- 获得http的请求方法 -- ngx.say("http的请求method: " .. ngx.req.get_method());

-- http的请求头内容 -- ngx.say("http的原始请求头内容: " .. ngx.req.raw_header());

-- 获得http的请求头信息 local myHeader = ngx.req.get_headers(); -- ngx.say("token: " .. myHeader.token); -- ngx.say("uid: " .. myHeader.uid);

-- 获得请求中的参数 local args = ngx.req.get_uri_args(); -- ngx.say("age: " .. args["age"]); -- ngx.say("birthday: " .. args["birthday"]);

-- 获得请求体body中的数据 ngx.req.read_body(); local body_data = ngx.req.get_post_args(); for key,value in pairs(body_data) do ngx.say(key, value); end

目标: 先查询缓存,如果缓存有数据,则在网关中判断返回即可。 如果网关中缓存不存在,则把请求向后端服务转发。 -- 导入工具类引用 local http = require('http'); local redis = require("redis_utils")

local get = http.get;

local args = ngx.req.get_uri_args(); local articleId = args["id"]; local articleKey = "REDIS_ARTICLE:" .. articleId;

local articleDetail = redis.get(articleKey);

if articleDetail ~= ngx.null then ngx.say("by openresty: " .. articleDetail); return; end

-- 发送请求 local result = get("/article/query", args); -- 返回响应 ngx.say("by springboot: " .. result); -- ngx.say("测试负载均衡 - 106");

点赞
收藏
评论区
推荐文章
荀勗 荀勗
5个月前
[24章]Qt 全流程实战企业级项目 - 云对象存储浏览器
下载地址1:https://pan.baidu.com/s/180fnOsA0EwGXcLb3icyw提取码:laa9下载地址2:https://pan.baidu.com/s/1adwzeyb1CKJrGiu2zpolQ提取码:a5p2Qt开发浏览器全流
赵颜 赵颜
5个月前
[16章]SpringBoot2 仿B站高性能前端+后端项目(2023新版)
资料地址1:https://pan.baidu.com/s/1cxQDKIi7iu1mGmjRr9a0Mw提取码:tz5s资料地址2:https://pan.baidu.com/s/1DjmuC6Id4oUCNVbxfgcMg提取码:qtf3今天给大家讲讲
赵颜 赵颜
5个月前
[15章]深入学习小程序框架底层原理,培养双线程思维
学习地址1:https://pan.baidu.com/s/1ridzu0mrj1vrfT07fdReuw提取码:3zd2学习地址2:https://pan.baidu.com/s/1SChnJCGf03sybLfyAnkCA提取码:c862前端高手特训从
赵嬷嬷 赵嬷嬷
5个月前
[升级16章+电子书]SpringBoot+Vue3 项目实战,打造企业级在线办公系统
学习地址1:https://pan.baidu.com/s/1gx9YoT3asP0fRdlwnBzXIQ提取码:ftyi学习地址2:https://share.weiyun.com/jVSDdcBU密码:cruqf9SpringBootVue3项目实战
赵嬷嬷 赵嬷嬷
4个月前
[16章]慕课甄选-2024年Flutter零基础极速入门到进阶实战
学习地址1:https://pan.baidu.com/s/1iOH2xMvdMyBAJla5PeHuUg提取码:hjhi学习地址2:https://pan.baidu.com/s/1Iwj10AL7jdum19WQz1jdA提取码:0n8xFlutter
赵嬷嬷 赵嬷嬷
3个月前
[31周]AI人工智能算法工程师体系课2024
学习地址1:https://pan.baidu.com/s/1wpfuPvDb4Y4BQEKPt7bc1A提取码:q7xz学习地址2:https://pan.baidu.com/s/1CYzDHRmYKDPb29MfKN0qlg提取码:2jt4今天给大家讲
鲍二家的 鲍二家的
2个月前
AI Agent智能应用从0到1定制开发(12章)
学习地址1:https://pan.baidu.com/s/1ccnoXsPCUg4eP5rSrD0UA提取码:o0mu学习地址2:https://pan.baidu.com/s/1JYJ6dMkwgx0XWQnCM6Q0A提取码:2m68AIAgent已
双寿 双寿
2个月前
[12章]AI Agent智能应用从0到1定制开发
学习地址1:https://pan.baidu.com/s/15IbktHy54IdZRg3g7PWWKQ提取码:v7lt学习地址2:https://pan.baidu.com/s/1JYJ6dMkwgx0XWQnCM6Q0A提取码:2m68AIAgent
鲍二家的 鲍二家的
1个月前
[7章]Go从入门到进阶,大厂案例全流程实践
学习地址1:https://pan.baidu.com/s/1kZq7Rc7PHBRYEzWL85FCA提取码:0udi学习地址2:https://pan.baidu.com/s/1Rr5G2U3YSbwhFTLMHH2keA提取码:j0viGo语言高效、
鲍二家的 鲍二家的
1个月前
前端跳槽突围课:React18底层源码深入剖析
学习地址1:https://pan.baidu.com/s/1DnzdWB9oCEMGOx9jvYjAjg提取码:hqw0学习地址2:https://pan.baidu.com/s/1kUlrpqlboZIrRmXpiT9TLw提取码:ur5i在当下就业环