《QDebug 2022年11月》
创始人
2024-03-05 01:49:08
0

一、Qt Widgets 问题交流

二、Qt Quick 问题交流

1.QtQuick.Dialogs 1.x 中的 MessageDialog 触发两次 accepted 、rejected

[QTBUG-94126] If inherit QApplication, the MessageDialog accepted signal is emitted twice. - Qt Bug Tracker

当使用 QApplication 而不是 QGuiApplication 时,MessageDialog 的 accepted、rejected 信号会触发两次,一种替代方案是使用 Qt.labs.platform 模块的 MessageDialog。

2.注册 QML 单例对象被 QML 引擎接管导致的释放问题

单例实现使用 static 对象,很明显是不能对这个单例指针 delete 的

AppManager *AppManager::getInstance()
{static AppManager instance;return &instance;
}

注册单例时可以设置为 QQmlEngine::CppOwnership,避免被 QML 引擎释放

    qmlRegisterSingletonType("Handy.Manager", 1, 0,"AppManager", [](QQmlEngine* qmlEngine, QJSEngine*){qmlEngine->setObjectOwnership(AppManager::getInstance(), QQmlEngine::CppOwnership);return AppManager::getInstance();});

3.Qt5.15 启用 QSG_RHI,子窗口 Window 调用 close 可能会导致下次显示空白

设置环境变量启用 QSG_RHI

qputenv("QSG_RHI", "1");

此时如果有 Window 类型的弹框,直接调用 close 或者点标题栏关闭,多点几次可能会触发异常,如果是 hide 似乎就能正常工作

Window {width: 640height: 480visible: truetitle: qsTr("Main")Button {text: "open"onClicked: w2.show()}Window {id: w2width: 300height: 200title: qsTr("Sub")Button {anchors.centerIn: parenttext: qsTr("hide")onClicked: w2.hide()}}
}

异常发生时会有提示,然后这个子窗口的内容就没法显示出来的,成了一个空白的窗口

Failed to resize D3D11 swapchain: Error 0x80070005: ????????
Failed to build or resize swapchain
Failed to present: Error 0x887a0001: ??ó???????????Ч????á???????????????????????????
???? D3D ????????????????????????????
Failed to end frame

 

三、其他

1.Qt5 QMediaPlayer 的 duration 不能立即获取

根据文档描述,Qt5 QMediaPlayer 的 duration 需要连接 durationChanged 信号来获取当前媒体的总时长。

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...
有效的括号 一、题目 给定一个只包括 '(',')','{','}'...