栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Qt开发奇葩问题总集

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Qt开发奇葩问题总集

Qt开发奇葩问题总集

文章目录

Qt开发奇葩问题总集

说明:使用 QColorDialog 控制台出现提示 未解决Qt 运行程序控制台 自动输出 CUserInputProcessor::onSetFocus in 之类的Qt 打开软件出现 缺库 api-ms-win-core-sysinfo-l1-2-o.dll

Qt 使用多线程连接信号槽 发生错误Qt 多线程 未解决 Qt 使用MSVC 编译器 显示中文字符 报错error: LNK2019

error: LNK2019 error: LNK2038error: C2131error: LNK2005

Cannot send events to objects owned by a different thread Cannot open include file: 'corecrt.h'

Cannot open include file: 'corecrt.h'Cannot open include file: 'Windows.h'

说明:

说明 主要记录一些 Qt 开发以及QtCreator 使用过程中遇到的奇葩问题 记录

有些已经解决(有些也晓不得为啥就能解决)有些还未解决

其实觉得问题奇葩 就是目前个人的知识水平还不够 晓不得为啥这样能解决 希望有路过的大佬懂的原因的能解下惑

使用 QColorDialog 控制台出现提示 未解决

使用 QColorDialog 控制台出现提示 也不是报错叭 但是看到总不舒服 202106171602 未解决

setGeometry: Unable to set geometry 400x400+2619+336 (frame: 416x439+2611+305) on QWidgetWindow/"QColorDialogClassWindow" on "\.DISPLAY2". Resulting geometry: 522x393+2619+336 (frame: 538x432+2611+305) margins: 8, 31, 8, 8 minimum size: 522x393 maximum size: 522x393 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=538,432 maxtrack=538,432)
Qt 运行程序控制台 自动输出 CUserInputProcessor::onSetFocus in 之类的

环境: win7 Qt Creator4.13.1 Qt5.12.10
现象描述:
QtCreator 运行程序 控制台自动弹出 换个项目依然是 但是不影响程序执行 就是有点看着不舒服 就是不爽。

CUserInputProcessor::onSetFocus in
CUserInputProcessor::onSetFocus out

百度网友解决办法是卸载百度输入法 运行的电脑上确实有百度输入法 同时 发现运行程序时鼠标点Mainwindow外面 输出out 里面输出in

换用讯飞输入法后控制台出现:

iFlyIMEEntry ::DllMain | strPath:D:Program Files (x86)iFlytekiFlyIME3.0.1727
iFlyIMEEntry::ImeInquire | pos1
::GetiflyimeModule | strBuf:D:Program Files (x86)iFlytekiFlyIME3.0.1727
::GetiflyimeModule | hModule:0x2edd0000iFlyIMEEntry::ImeInquire | pos2
iFlyIMEEntry::ImeSelect | pos1iFlyIMEEntry::ImeSelect | pos2iFlyIMEEntry::ImeSelect | pos1iFlyIMEEntry::ImeSelect | pos2

解决办法: 卸载百度输入法

出现原因: 希望路过的大佬能为我解解惑

Qt 打开软件出现 缺库 api-ms-win-core-sysinfo-l1-2-o.dll

环境:QtCreater4.13.1 Qt5.12.10

系统:Win7

出现问题: 忘记截图了 虽然不影响使用 但看起来不舒服

解决办法:

1、下载 api-ms-win-core-sysinfo-l1-2-o.dll

2、将dll 放到 C:WindowsSystem32 目录下 如果出现了两次提示没有api-ms-win-core-sysinfo-l1-2-o.dll 分别把 32(C:WindowsSystem32)和64位(C:WindowsSysWOW64)的dll放到目录下

说明:不知道是dll的原因还是啥 C:WindowsSystem32目录下放 32位的提示错误 最后是交换放置

Qt 使用多线程连接信号槽 发生错误

环境:QtCreater4.13.1 Qt5.12.10

系统:Win7

QObject::connect: Cannot queue arguments of type 'QList'
(Make sure 'QList' is registered using qRegistermetaType()

解决办法:

connect 之前调用 qRegistermetaType()注册数据类型 (自定义的数据类型PsdData)

#include 
qRegistermetaType>("QList");
qRegistermetaType>("QList");
Qt 多线程 未解决
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
CSProxy refcount 22
==========> ExitInstance :gLayerInfo delete 873638104<==============Unload CSProxy from E:Works_ProjectDMCADMCA_PSDSoftwarebuild-DMCA_PSD-Desktop_Qt_5_12_10_MinGW_32_bitdebugDMCA_PSD.exe...
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Qt 使用MSVC 编译器 显示中文字符 报错
 error: C2001: newline in constant
 .......
 error: C3872: '0xe11b': this character is not allowed in an identifier
 

解决办法:将当前文档转化为 UTF-8 使用QStringLiteral()包裹字符串

保存UTF-8: (都需要用QStringLiteral包裹中文字符)

1、使用记事本另存为 选择UTF-8

2、Qt Creator 工具->选项->文本编辑器->Behavior->文件编码 默认编码格式->UTF-8 UTF-8 BOM->如果编码是UTF-8则添加

error: LNK2019
device_sapp.obj:-1: error: LNK2019: unresolved external symbol "public: virtual __cdecl device_sapp::~device_sapp(void)" (??1device_sapp@@UEAA@XZ) referenced in function "public: virtual void * __cdecl device_sapp::`scalar deleting destructor'(unsigned int)" (??_Gdevice_sapp@@UEAAPEAXI@Z)

虚基类的构造函数与析构函数 与继承的类的析构函数重复

Exception at 0x7fefdadb87d, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in dwrite!DWriteCreateFactory
Exception at 0x7fefdadb87d, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance) in dwrite!DWriteCreateFactory
error: LNK2019
qcustomplot.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QPrinter::QPrinter(enum QPrinter::PrinterMode)" (__imp_??0QPrinter@@QEAA@W4PrinterMode@0@@Z) referenced in function "public: bool __cdecl QCustomPlot::savePdf(class QString const &,int,int,enum QCP::ExportPen,class QString const &,class QString const &)" (?savePdf@QCustomPlot@@QEAA_NAEBVQString@@HHW4ExportPen@QCP@@00@Z)

出现这样的错误一般是声明了函数没有实现其定义,比如这里提示的是没有自定义类MyWidget的实现函数。如果你已经检查了确定定义是有的,比如我这个就确实有定义了的,那就把该项目编译出的build debug文件夹给删除掉,再重新编译,注意是编译出来的整个文件夹一起删,而不是clean清除后重新构建。

忘记添加: printsupport

error: LNK2038
SmartFFT.lib(smartfft.obj):-1: error: LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

原因:用release链接到一个debug编译的lib或者debug模式链接到一个release编译的lib

error: C2131
error: C2131: expression did not evaluate to a constant

原因:MSVC编译器 使用变量定义数组的尺寸

error: LNK2005
error: LNK2005: "void __cdecl doFFT(short *,int,double *)" (?doFFT@@YAXPEAFHPEAN@Z) already defined in main.obj

原因:需要使用static定义 函数为静态方法

Cannot send events to objects owned by a different thread

环境:QtCreater4.13.1 Qt5.12.10

系统:Win7

问题描述:Qt 使用std::thread调用了主线程的对象

ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 0x0xdbd5b20. Receiver 'MainWindow' (of type 'MainWindow') was created in thread 0x0x364090", file kernelqcoreapplication.cpp, line 578
(Press Retry to debug the application)

解决办法:使用Qt的的信号槽机制跨线程通信

Cannot open include file: ‘corecrt.h’

环境:QtCreater4.13.1 Qt5.12.10

系统:Win7

原因是更改系统之前安装的Windows SDK版本

Cannot open include file: ‘corecrt.h’
D:Program Files (x86)Microsoft Visual Studio 14.0VCincludecrtdefs.h:10: error: C1083: Cannot open include file: 'corecrt.h': No such file or directory
Cannot open include file: ‘Windows.h’
E:Works_ProjectSpectrum_AnalyzerPCIESPEED_APP_winAPP_winPcieSpeedpcie_fun.c:4: error: C1083: Cannot open include file: 'Windows.h': No such file or directory

1、尝试修改系统环境变量 未解决

2、通过baidu 在Pro里面链接 库 能解决第一个问题 但会出现第二个问题更严重 (治标不治本) 未解决

INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x64"

(我的个人想法出现问题的大概率需要在哪里重新配置一下就好)

3、没有找到再哪里找到可以配置的地方 于是重新装了Qt 依然 未解决

4、但是再次打开Qt发现里面的配置配色跟卸载前一样 想到Qt会把配置文件放到用户目录下 解决

C:Users用户AppDataRoamingQtProject

先备份一下文档 并删除 再次打开QtCreator 这时候打开花的时间有点长 它重新从系统获取了配置 这时候重新测试没有报错

说明: 遇到这种问题可以不用卸载Qt 直接删除 这个文件就行 但之前辛苦配置出自己的工作环境就搞掉 需要对QtProject每个文件设置什么东西了解下 出现问题删除对应文件即可

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/784406.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号