当前位置: 首页 > 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;
}

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • springboot二手书资源管理系统-计算机毕业设计源码26338
  • [VBA]使用VBA在Excel中 操作 形状shape 对象
  • 全屏组件封装(react18+antd)
  • # 服务治理中间件详解:Spring Cloud与Dubbo
  • 【实现开机自动下载原神(bat脚本)1.0】
  • PythonStudio 控件使用常用方式(十六)TButtonedEdit
  • 在国产芯片上实现YOLOv5/v8图像AI识别-【2.4】导出RKNN模型(第一部分:模型修改)更多内容见视频
  • Midjourney研究笔记丨05图生图:垫图,让机器人为你提供有效关键词
  • LabVIEW中的Reverse String函数与字节序转换
  • MySQL4多表查询 内连接
  • 支付宝开放平台竟出现一张神秘人脸!
  • uniapp(scroll-view)设置show-scrollbar无效
  • RHCA III之路---EX436-5
  • 在Quartz.Net中使用Scoped Service
  • Vue:使用html2canvas将数据导出到PDF上(含分页)
  • 【刷算法】从上往下打印二叉树
  • CEF与代理
  • Javascript编码规范
  • js中的正则表达式入门
  • leetcode46 Permutation 排列组合
  • SegmentFault 2015 Top Rank
  • 官方新出的 Kotlin 扩展库 KTX,到底帮你干了什么?
  • ------- 计算机网络基础
  • #stm32驱动外设模块总结w5500模块
  • (007)XHTML文档之标题——h1~h6
  • (3)STL算法之搜索
  • (done) NLP “bag-of-words“ 方法 (带有二元分类和多元分类两个例子)词袋模型、BoW
  • (附源码)springboot炼糖厂地磅全自动控制系统 毕业设计 341357
  • (剑指Offer)面试题34:丑数
  • (七)Activiti-modeler中文支持
  • (一) storm的集群安装与配置
  • (一)spring cloud微服务分布式云架构 - Spring Cloud简介
  • (一)u-boot-nand.bin的下载
  • (转)大道至简,职场上做人做事做管理
  • *** 2003
  • *算法训练(leetcode)第三十九天 | 115. 不同的子序列、583. 两个字符串的删除操作、72. 编辑距离
  • *算法训练(leetcode)第四十七天 | 并查集理论基础、107. 寻找存在的路径
  • .net core 6 集成 elasticsearch 并 使用分词器
  • .NET 程序如何获取图片的宽高(框架自带多种方法的不同性能)
  • .NET/C# 检测电脑上安装的 .NET Framework 的版本
  • .NET/C# 判断某个类是否是泛型类型或泛型接口的子类型
  • .NET/C#⾯试题汇总系列:⾯向对象
  • .Net下使用 Geb.Video.FFMPEG 操作视频文件
  • .sh文件怎么运行_创建优化的Go镜像文件以及踩过的坑
  • @Import注解详解
  • [3D游戏开发实践] Cocos Cyberpunk 源码解读-高中低端机性能适配策略
  • [BUG]Datax写入数据到psql报不能序列化特殊字符
  • [C++]C++基础知识概述
  • [hdu 3065] 病毒侵袭持续中 [AC自动机] [病毒特征码匹配]
  • [Hive] CTE 通用表达式 WITH关键字
  • [LeetCode] 148. Sort List 链表排序
  • [LeetCode] NO. 169 Majority Element
  • [LWC小知识] 标准lightning-input-field怎么取得变更值(onchange)
  • [Machine Learning] 领域适应和迁移学习
  • [Meachines] Lame smbd3.0-RCE