必须在QWidget&之前构造一个QApplication。无效的参数传递给C运行时函数 [英] Must construct a QApplication before a QWidget & Invalid parameter passed to C runtime function

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

问题描述

我已经完成了将应用程序从Qt4迁移到Qt5的过程,它可以编译,但是它在任何时候都崩溃了。我正在调试它,并试图找到原因,但是我已经走到了尽头:

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:

这里是堆栈:

main.cpp第373行:

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."

应用程序显示

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

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

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&之前构造一个QApplication。无效的参数传递给C运行时函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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