简体   繁体   English

cpp QT 处的访问冲突读取位置

[英]Access violation reading location at cpp QT

I have problem with next constructor of QPixmap:我对 QPixmap 的下一个构造函数有疑问:

QPixmap* map = new QPixmap(100, 100);

There`s exception thrown , shown by visual studio.抛出异常,由 Visual Studio 显示。 Access violation reading location 0x0000000000000000访问冲突读取位置 0x0000000000000000

I want to get empty field for drawing with current width and height, what should I do?我想用当前宽度和高度绘制空白字段,我该怎么办?

More specifically, you are trying to use QPixmap in a non-gui application.更具体地说,您正在尝试在非 gui 应用程序中使用 QPixmap。

https://bugreports.qt.io/browse/QTBUG-64125 https://bugreports.qt.io/browse/QTBUG-64125

QPixmap is connected to the underlying GUI platform, and hence requires QGuiApplication/QApplication to be initialized. QPixmap 连接到底层 GUI 平台,因此需要初始化 QGuiApplication/QApplication。

QImage can be used instead here.此处可以使用 QImage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM