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

Qt之Gui

组件依赖关系

在这里插入图片描述

应用

QGuiApplication
QApplication
QCoreApplication

QApplication:widget对应的应用
QGuiApplication :gui对应的应用
QCoreApplication :无gui对应的应用

widget

QWidget
QMainWindow
QWidgetWindow
QWindow
QPlatformIntegration
QPlatformWindow

QPlatformIntegration:平台抽象
QPlatformWindow :平台 抽象窗口

windows平台

QPlatformIntegration
QWindowsIntegration
QPlatformWindow
QWindowsBaseWindow
QWindowsWindow
QWindowsDesktopWindow
QWindowsForeignWindow
QWindowsContext

在QWindowsIntegration创建createPlatformWindow时,其先创建QWindowsWindowData::create

QWindowsWindowDataWindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
{WindowData result;result.flags = flags;const auto appinst = reinterpret_cast<HINSTANCE>(GetModuleHandle(nullptr));const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);const QScreen *screen{};const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry,defaultWindowWidth, defaultWindowHeight,&screen);if (title.isEmpty() && (result.flags & Qt::WindowTitleHint))title = topLevel ? qAppName() : w->objectName();const auto *titleUtf16 = reinterpret_cast<const wchar_t *>(title.utf16());const auto *classNameUtf16 = reinterpret_cast<const wchar_t *>(windowClassName.utf16());// Capture events before CreateWindowEx() returns. The context is cleared in// the QWindowsWindow constructor.const QWindowCreationContextPtr context(new QWindowCreationContext(w, screen, data.geometry,rect, data.customMargins,style, exStyle));QWindowsContext::instance()->setWindowCreationContext(context);const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME));QMargins invMargins = topLevel && hasFrame && QWindowsGeometryHint::positionIncludesFrame(w)? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins();qCDebug(lcQpaWindows).nospace()<< "CreateWindowEx: " << w << " class=" << windowClassName << " title=" << title<< '\n' << *this << "\nrequested: " << rect << ": "<< context->frameWidth << 'x' <<  context->frameHeight<< '+' << context->frameX << '+' << context->frameY<< " custom margins: " << context->customMargins<< " invisible margins: " << invMargins;QPoint pos = calcPosition(w, context, invMargins);// Mirror the position when creating on a parent in RTL mode, ditto for the obtained geometry.int mirrorParentWidth = 0;if (!w->isTopLevel() && QWindowsBaseWindow::isRtlLayout(parentHandle)) {RECT rect;GetClientRect(parentHandle, &rect);mirrorParentWidth = rect.right;}if (mirrorParentWidth != 0 && pos.x() != CW_USEDEFAULT && context->frameWidth != CW_USEDEFAULT)pos.setX(mirrorParentWidth - context->frameWidth - pos.x());result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16,style,pos.x(), pos.y(),context->frameWidth, context->frameHeight,parentHandle, nullptr, appinst, nullptr);qCDebug(lcQpaWindows).nospace()<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "<< context->obtainedPos << context->obtainedSize << ' ' << context->margins;if (!result.hwnd) {qErrnoWarning("%s: CreateWindowEx failed", __FUNCTION__);return result;}if (mirrorParentWidth != 0) {context->obtainedPos.setX(mirrorParentWidth - context->obtainedSize.width()-  context->obtainedPos.x());}QRect obtainedGeometry(context->obtainedPos, context->obtainedSize);result.geometry = obtainedGeometry;result.fullFrameMargins = context->margins;result.embedded = embedded;result.hasFrame = hasFrame;result.customMargins = context->customMargins;return result;
}

内部会先注册registerWindowClass,设置窗口的处理函数registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon);
qWindowsWndProc处理函数主要是调用 QWindowsContext的windowsProc

QString QWindowsContext::registerWindowClass(QString cname,WNDPROC proc,unsigned style,HBRUSH brush,bool icon)
{// since multiple Qt versions can be used in one process// each one has to have window class names with a unique name// The first instance gets the unmodified name; if the class// has already been registered by another instance of Qt then// add a UUID. The check needs to be performed for each name// in case new message windows are added (QTBUG-81347).const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));WNDCLASS wcinfo;const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) == TRUE&& wcinfo.lpfnWndProc != proc;if (classExists)cname += QUuid::createUuid().toString();if (d->m_registeredWindowClassNames.contains(cname))        // already registered in our listreturn cname;WNDCLASSEX wc;wc.cbSize       = sizeof(WNDCLASSEX);wc.style        = style;wc.lpfnWndProc  = proc;wc.cbClsExtra   = 0;wc.cbWndExtra   = 0;wc.hInstance    = appInstance;wc.hCursor      = nullptr;wc.hbrBackground = brush;if (icon) {wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));if (wc.hIcon) {int sw = GetSystemMetrics(SM_CXSMICON);int sh = GetSystemMetrics(SM_CYSMICON);wc.hIconSm = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, sw, sh, 0));} else {wc.hIcon = static_cast<HICON>(LoadImage(nullptr, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED));wc.hIconSm = nullptr;}} else {wc.hIcon    = nullptr;wc.hIconSm  = nullptr;}wc.lpszMenuName  = nullptr;wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());ATOM atom = RegisterClassEx(&wc);if (!atom)qErrnoWarning("QApplication::regClass: Registering window class '%s' failed.",qPrintable(cname));d->m_registeredWindowClassNames.insert(cname);qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname<< " style=0x" << Qt::hex << style << Qt::dec<< " brush=" << brush << " icon=" << icon << " atom=" << atom;return cname;
}

相关文章:

Qt之Gui

组件依赖关系 应用 #mermaid-svg-GADicZtZJRVVUeiF {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-GADicZtZJRVVUeiF .error-icon{fill:#552222;}#mermaid-svg-GADicZtZJRVVUeiF .error-text{fill:#552222;stroke:#…...

Linux操作系统之进程信号

进程信号 一、信号1、概念2、系统定义的信号列表3、常见的信号处理方式 二、产生信号的方式1、终端按键&#xff08;1&#xff09;组合键&#xff08;2&#xff09;示例代码&#xff08;3&#xff09;运行结果 2、调用系统函数&#xff08;1&#xff09;kill命令&#xff08;2&…...

科普文:微服务之Spring Cloud Alibaba消息队列组件RocketMQ工作原理

概叙 本文探讨 RocketMQ 的事务消息原理&#xff0c;并从源码角度进行分析&#xff0c;以及事务消息适合什么场景&#xff0c;使用事务消息需要注意哪些事项。 同时详细介绍RocketMQ 事务消息的基本流程&#xff0c;并通过源码分析揭示了其内部实现原理&#xff0c;尽管事务消…...

黑马头条vue2.0项目实战(五)——首页—频道编辑

目录 1. 使用页面弹出层 1.1 页面弹出层简单使用 1.2 创建频道编辑组件 1.3 页面布局 2. 展示我的频道 3. 展示推荐频道列表 3.1 获取所有频道 3.2 处理展示推荐频道 4. 添加频道 5. 编辑频道 5.1 处理编辑状态 5.2 切换频道 5.3 让激活频道高亮 5.4 删除频道 6.…...

Java:基础语法

基础语法 1. 基本结构类和方法 2. 变量和数据类型基本数据类型引用数据类型 3. 操作符算术操作符比较操作符逻辑操作符 4. 控制结构条件语句循环语句 5. 数组6. 方法7. 面向对象编程类和对象继承多态 8. 异常处理9. 常用类库 1. 基本结构 类和方法 Java程序的基本单位是类&am…...

安装bedtools详细步骤和详细介绍bedtools用法

安装bedtools详细步骤和详细介绍bedtools用法 一、安装bedtools详细步骤下载解压安装编译依赖编译设置环境变量激活环境变量执行命令查看版本二、详细介绍bedtools用法使用bedtools示例用法bedtools intersectbedtools bamtobedbedtools window一、安装bedtools详细步骤 下载 …...

21 - grace数据处理 - 补充 - 泄露误差改正 - Slepian局部谱分析法(一) - slepian分析法理论理解

21 - grace数据处理 - 泄露误差改正 - Slepian局部谱分析法 - slepian分析法理论理解 0 引言1 slepian谱分析法1.1 slepian谱分析法AI解释1.2 基于slepian谱分析法的GRACE数据处理应用2 slepian谱分析法关键过程实现2.1 求解正定特征方程2.2 计算slepian基函数2.3 计算Shannon数…...

WLAN国家码与信道顺从表

国家码和信道顺从表及信道功率限制 不同的国家和地区规定了在本国或本地区可以使用的信道、射频信号在信道中的最大发射功率。工作在不同信道的射频信号&#xff0c;信号强度可能会有差别。国家码和信道顺从表、各信道的功率限制值、信道编号和频率对照关系请参见国家码和信道…...

行为型设计模式1:状态/策略/命令

行为型设计模式&#xff1a;状态/策略/命令 (qq.com)...

【知识专栏丨python数分实战】天猫订单数据分析及可视化|taobao天猫订单接口

今天这篇文章将给大家介绍天猫订单数据分析及可视化案例。 import pandas as pdimport numpy as npfrom pyecharts.charts import Pie,Bar,Line,Map,Map3D,Funnelfrom pyecharts import options as optsimport matplotlib.pyplot as pltimport warningsimport seaborn as snsfr…...

[kimi笔记]为什么csc.exe不可以双击运行

csc.exe 是 C# 编译器的可执行文件&#xff0c;它是 .NET Framework 的一部分&#xff0c;用于编译 C# 源代码文件&#xff08; .cs 文件&#xff09;生成可执行文件&#xff08; .exe 文件&#xff09;或其他类型的程序集。 csc.exe 不能通过双击运行的原因有以下几点&…...

护眼大路灯哪个牌子好?2024学生护眼大路灯推荐

护眼大路灯哪个牌子好&#xff1f;护眼大路灯不仅能够提供日常的光线照明&#xff0c;还模拟了太阳光光线&#xff0c;使在室内用眼学习也能够有着自然光般的舒适感&#xff0c;但现在市场上有许多对产品质量把控不过关、光线效果欠佳、存有安全隐患的劣质护眼大路灯产品&#…...

Vue项目中手搓滑动校验模块-demo

实现代码 SliderCheck.vue <template><div class"drag" ref"dragDiv"><div class"drag_bg" ref"dragBg"></div><div class"drag_text" ref"dragText">{{ confirmWords }}</di…...

Socket如何实现客户端和服务器间的通信

Socket 是实现网络通信的一种机制&#xff0c;它允许在不同主机之间的进程通过网络进行数据交换。下面我将简要介绍如何使用 Socket 实现客户端和服务器间的通信。 客户端-服务器通信步骤&#xff1a; 服务器端&#xff1a; 创建服务器端 Socket&#xff1a; 服务器端通过创…...

基于Spring boot + Vue的校园论坛

作者的B站地址&#xff1a;程序员云翼的个人空间-程序员云翼个人主页-哔哩哔哩视频 csdn地址&#xff1a;程序员云翼-CSDN博客 1.项目技术栈&#xff1a; 前后端分离的项目 后端&#xff1a;Springboot MybatisPlus 前端&#xff1a;Vue ElementUI 数据库&#xff1a; …...

RabbitMQ高级特性 - 生产者消息确认机制

文章目录 生产者消息确认机制概述confirm 代码实现return 代码实现 生产者消息确认机制 概述 为了保证信息 从生产者 发送到 队列&#xff0c;因此引入了生产者的消息确认机制. RabbitMQ 提供了两种解决方案&#xff1a; 通过事务机制实现.通过发送确认机制&#xff08;confi…...

webpack的loader机制

webpack的loader机制 loader本质上就是导出函数的JavaScript模块。导出的函数&#xff0c;可以用来实现内容的转换。 /* * param{string|Buffer} content 源文件的内容 * param{object} [map] SourceMap数据 * param{any} [meta] meta数据&#xff0c;可以是任何数据 * */ fu…...

(STM32笔记)十一、通过EXTI外部中断实现 按键控制LED

我用的是正点的STM32F103来进行学习&#xff0c;板子和教程是野火的指南者。 之后的这个系列笔记开头未标明的话&#xff0c;用的也是这个板子和教程。 十一、通过EXTI外部中断实现 按键控制LED 十一、通过EXTI外部中断实现 按键控制LED1、按键模块按键原理图按键程序思路 2、中…...

假如家里太大了,wifi连不上了怎么办

最近有个土豪朋友抱怨&#xff0c;他家里太大了&#xff0c;一个路由器的Wi-Fi信号根本无法覆盖他们家的每个房间&#xff0c;都没办法上网看奥运会比赛了。&#xff08;还好我是穷人&#xff0c;就没有这种烦恼T_T&#xff09;。 然后我问他为何不用一个路由器作主路由器&…...

elementPlus 设置el-input文本域固定高度和禁止下拉

elementPlus 设置el-input文本域固定高度和禁止下拉 话不多说直接上代码 // resize"none" 禁止下拉<el-inputv-model"textarea"style"width: 240px"type"textarea"resize"none"placeholder"请输入"/>// 设…...

docker详细操作--未完待续

docker介绍 docker官网: Docker&#xff1a;加速容器应用程序开发 harbor官网&#xff1a;Harbor - Harbor 中文 使用docker加速器: Docker镜像极速下载服务 - 毫秒镜像 是什么 Docker 是一种开源的容器化平台&#xff0c;用于将应用程序及其依赖项&#xff08;如库、运行时环…...

1.3 VSCode安装与环境配置

进入网址Visual Studio Code - Code Editing. Redefined下载.deb文件&#xff0c;然后打开终端&#xff0c;进入下载文件夹&#xff0c;键入命令 sudo dpkg -i code_1.100.3-1748872405_amd64.deb 在终端键入命令code即启动vscode 需要安装插件列表 1.Chinese简化 2.ros …...

CocosCreator 之 JavaScript/TypeScript和Java的相互交互

引擎版本&#xff1a; 3.8.1 语言&#xff1a; JavaScript/TypeScript、C、Java 环境&#xff1a;Window 参考&#xff1a;Java原生反射机制 您好&#xff0c;我是鹤九日&#xff01; 回顾 在上篇文章中&#xff1a;CocosCreator Android项目接入UnityAds 广告SDK。 我们简单讲…...

MySQL中【正则表达式】用法

MySQL 中正则表达式通过 REGEXP 或 RLIKE 操作符实现&#xff08;两者等价&#xff09;&#xff0c;用于在 WHERE 子句中进行复杂的字符串模式匹配。以下是核心用法和示例&#xff1a; 一、基础语法 SELECT column_name FROM table_name WHERE column_name REGEXP pattern; …...

3-11单元格区域边界定位(End属性)学习笔记

返回一个Range 对象&#xff0c;只读。该对象代表包含源区域的区域上端下端左端右端的最后一个单元格。等同于按键 End 向上键(End(xlUp))、End向下键(End(xlDown))、End向左键(End(xlToLeft)End向右键(End(xlToRight)) 注意&#xff1a;它移动的位置必须是相连的有内容的单元格…...

什么是Ansible Jinja2

理解 Ansible Jinja2 模板 Ansible 是一款功能强大的开源自动化工具&#xff0c;可让您无缝地管理和配置系统。Ansible 的一大亮点是它使用 Jinja2 模板&#xff0c;允许您根据变量数据动态生成文件、配置设置和脚本。本文将向您介绍 Ansible 中的 Jinja2 模板&#xff0c;并通…...

Angular微前端架构:Module Federation + ngx-build-plus (Webpack)

以下是一个完整的 Angular 微前端示例&#xff0c;其中使用的是 Module Federation 和 npx-build-plus 实现了主应用&#xff08;Shell&#xff09;与子应用&#xff08;Remote&#xff09;的集成。 &#x1f6e0;️ 项目结构 angular-mf/ ├── shell-app/ # 主应用&…...

iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈

在日常iOS开发过程中&#xff0c;性能问题往往是最令人头疼的一类Bug。尤其是在App上线前的压测阶段或是处理用户反馈的高发期&#xff0c;开发者往往需要面对卡顿、崩溃、能耗异常、日志混乱等一系列问题。这些问题表面上看似偶发&#xff0c;但背后往往隐藏着系统资源调度不当…...

Python Ovito统计金刚石结构数量

大家好,我是小马老师。 本文介绍python ovito方法统计金刚石结构的方法。 Ovito Identify diamond structure命令可以识别和统计金刚石结构,但是无法直接输出结构的变化情况。 本文使用python调用ovito包的方法,可以持续统计各步的金刚石结构,具体代码如下: from ovito…...

纯 Java 项目(非 SpringBoot)集成 Mybatis-Plus 和 Mybatis-Plus-Join

纯 Java 项目&#xff08;非 SpringBoot&#xff09;集成 Mybatis-Plus 和 Mybatis-Plus-Join 1、依赖1.1、依赖版本1.2、pom.xml 2、代码2.1、SqlSession 构造器2.2、MybatisPlus代码生成器2.3、获取 config.yml 配置2.3.1、config.yml2.3.2、项目配置类 2.4、ftl 模板2.4.1、…...