当前位置: 首页 > 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"请输入"/>// 设…...

Zustand 状态管理库:极简而强大的解决方案

Zustand 是一个轻量级、快速和可扩展的状态管理库&#xff0c;特别适合 React 应用。它以简洁的 API 和高效的性能解决了 Redux 等状态管理方案中的繁琐问题。 核心优势对比 基本使用指南 1. 创建 Store // store.js import create from zustandconst useStore create((set)…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

服务器硬防的应用场景都有哪些?

服务器硬防是指一种通过硬件设备层面的安全措施来防御服务器系统受到网络攻击的方式&#xff0c;避免服务器受到各种恶意攻击和网络威胁&#xff0c;那么&#xff0c;服务器硬防通常都会应用在哪些场景当中呢&#xff1f; 硬防服务器中一般会配备入侵检测系统和预防系统&#x…...

USB Over IP专用硬件的5个特点

USB over IP技术通过将USB协议数据封装在标准TCP/IP网络数据包中&#xff0c;从根本上改变了USB连接。这允许客户端通过局域网或广域网远程访问和控制物理连接到服务器的USB设备&#xff08;如专用硬件设备&#xff09;&#xff0c;从而消除了直接物理连接的需要。USB over IP的…...

CVE-2020-17519源码分析与漏洞复现(Flink 任意文件读取)

漏洞概览 漏洞名称&#xff1a;Apache Flink REST API 任意文件读取漏洞CVE编号&#xff1a;CVE-2020-17519CVSS评分&#xff1a;7.5影响版本&#xff1a;Apache Flink 1.11.0、1.11.1、1.11.2修复版本&#xff1a;≥ 1.11.3 或 ≥ 1.12.0漏洞类型&#xff1a;路径遍历&#x…...

Linux 内存管理实战精讲:核心原理与面试常考点全解析

Linux 内存管理实战精讲&#xff1a;核心原理与面试常考点全解析 Linux 内核内存管理是系统设计中最复杂但也最核心的模块之一。它不仅支撑着虚拟内存机制、物理内存分配、进程隔离与资源复用&#xff0c;还直接决定系统运行的性能与稳定性。无论你是嵌入式开发者、内核调试工…...

iview框架主题色的应用

1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题&#xff0c;无需引入&#xff0c;直接可…...

NPOI Excel用OLE对象的形式插入文件附件以及插入图片

static void Main(string[] args) {XlsWithObjData();Console.WriteLine("输出完成"); }static void XlsWithObjData() {// 创建工作簿和单元格,只有HSSFWorkbook,XSSFWorkbook不可以HSSFWorkbook workbook new HSSFWorkbook();HSSFSheet sheet (HSSFSheet)workboo…...

STM32---外部32.768K晶振(LSE)无法起振问题

晶振是否起振主要就检查两个1、晶振与MCU是否兼容&#xff1b;2、晶振的负载电容是否匹配 目录 一、判断晶振与MCU是否兼容 二、判断负载电容是否匹配 1. 晶振负载电容&#xff08;CL&#xff09;与匹配电容&#xff08;CL1、CL2&#xff09;的关系 2. 如何选择 CL1 和 CL…...

PHP 8.5 即将发布:管道操作符、强力调试

前不久&#xff0c;PHP宣布了即将在 2025 年 11 月 20 日 正式发布的 PHP 8.5&#xff01;作为 PHP 语言的又一次重要迭代&#xff0c;PHP 8.5 承诺带来一系列旨在提升代码可读性、健壮性以及开发者效率的改进。而更令人兴奋的是&#xff0c;借助强大的本地开发环境 ServBay&am…...