使用Qt 5.7,Windows 7中,MinGW的32位,下面的程序:QPainter的#的drawText SEG在initializeDb
#include <QImage>
#include <QPainter>
int main() {
QImage i(100, 100, QImage::Format_RGB888);
QPainter p(&i);
p.drawText(0, 0, "abc"); // line 7
}
上
p.drawText
呼叫
波段故障,給以下堆棧跟蹤,它與initializeDb
結束:
1 initializeDb qfontdatabase.cpp 896 0x7930ed0
2 QFontDatabase::findFont qfontdatabase.cpp 2640 0x79361f6
3 QFontDatabase::load qfontdatabase.cpp 2795 0x7936b5e
4 QFontPrivate::engineForScript qfont.cpp 215 0x79194ff
5 QTextEngine::fontEngine qtextengine.cpp 2094 0x793d24b
6 QTextEngine::shapeText qtextengine.cpp 1000 0x7938c0b
7 QTextEngine::shape qtextengine.cpp 1534 0x793b090
8 QTextEngine::shapeLine qtextengine.cpp 938 0x793884a
9 QPainter::drawText qpainter.cpp 5877 0x7a3dc91
10 QPainter::drawText qpainter.cpp 5700 0x7a3cfe6
11 QPainter::drawText qpainter.h 890 0x402a1e
12 main main.cpp 7 0x4016b6
爲什麼會發生這種情況,如何使它不發生?
的pro文件,爲了完整性:
QT += core gui
CONFIG += c++11
TARGET = untitled18
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
。這是一個命令行實用程序,其生成圖像。
注意:添加QCoreApplication
沒有什麼區別。
嘗試使用QApplication而不是QCoreApplication。 –