调试:QWidget:必须在QWidget和QWidget之前构建一个QApplication传递给C运行时功能的参数无效 [英] Debugging: QWidget: Must construct a QApplication before a QWidget & Invalid parameter passed to C runtime function

查看:176
本文介绍了调试:QWidget:必须在QWidget和QWidget之前构建一个QApplication传递给C运行时功能的参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了从Qt4迁移到Qt5的应用程序,它的编译和除了它以外的一切都崩溃了。我正在调试它,并试图找到为什么,但我已经到了一个死胡同:



这是堆栈:





main.cpp第373行:

  TouchSwibz w(NULL,NULL,renderMode?renderMode:AppSettings :: RASTERMODE); 

当它到达断点,我尝试进一步,它崩溃与通常的


此应用程序请求运行时以
异常方式终止它。


而且aplication输出显示

  QWidget:必须在QWidget $之前构建一个QApplication b $ b传递给C运行时函数的参数无效。 
传递给C运行时函数的参数无效。

我以为可能是因为在创建主窗口时正在初始化窗口小部件,但是什么可以解决这个吗?什么是好的解决方法?我甚至不知道这是否是真正的问题。
我在Windows 7 x64下使用Qt 5.2.1编译,并用mingw 4.8 32bit进行编译,应用程序也在32bits中。一切都是用相同的工具包编译的。
我不知道我可以提供什么其他有用的信息。我尝试在QwtSlider构造函数中进行,但是我不能。

解决方案

我通过在调试模式下编译所有的库来解决它,在调试模式下构建应用程序时,库将处于释放模式,将导致未定义的行为。


I finished migrating an application from Qt4 to Qt5, it compiles and everything but it crashes at a certain point. I am debugging it and trying to find why but I have reached a dead end:

Here is the stack:

main.cpp line 373:

TouchSwibz w(NULL, NULL, renderMode ? renderMode : AppSettings::RASTERMODE);

When it reaches the breakpoint and I try to go further, it crashes with the usual

"This application has requested the Runtime to terminate it in an unusual way."

And the aplication output shows

QWidget: Must construct a QApplication before a QWidget
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.

I have thought maybe its because the widget is being initialized when the main window is being created, but what can be done to solve this? What would be a good workaround? I dont even know if this is the real issue. I work under Windows 7 x64 using Qt 5.2.1 and compiling with mingw 4.8 32bit, the application is in 32bits also. Everything is compiled with the same kit. I dont know what other useful information I can provide. I tried stepping inside the QwtSlider constructor but I cant.

解决方案

I managed to solve it by compiling all the libraries in debug mode, turns out having libraries in release mode while building your application in debug mode will make undefined behaviour happen.

这篇关于调试:QWidget:必须在QWidget和QWidget之前构建一个QApplication传递给C运行时功能的参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆