[Qt-interest] QPainter.drawText on windows: Access violation
Yanhao Zhu
yanhaozhu at gmail.com
Thu Jul 2 15:14:41 CEST 2009
Thank you so much, Patrick! That fixed the error. Appreciate your help
very much!
--Yanhao
On Thu, Jul 2, 2009 at 1:41 AM, Patrick Vollebregt<jeet.nl at gmail.com> wrote:
> Hi,
>
> Change QCoreApplication in QApplication and it should work. Maybe (haven't
> really looked into it) some initialization regarding palettes is done in
> QApplication, which isn't in QCoreApplication.
>
> Kinds regards,
>
> Patrick.
>>
>> Hi, all,
>>
>> I keep getting [Access violation] error with QPainter::drawText method
>> on windows. Here is the very simple code I used:
>>
>> -------------------------------------------------------------
>> #include <QtCore/QCoreApplication>
>> #include <QImage>
>> #include <QPainter>
>> #include <QFont>
>>
>> int main(int argc, char *argv[])
>> {
>> QCoreApplication a(argc, argv);
>>
>> QFont font("Lucida Console", 16);
>>
>> QImage image(256, 256, QImage::Format_ARGB32);
>>
>> QPainter painter(&image);
>> painter.setFont(font);
>> painter.drawText(10, 100, "Hello, world!");
>>
>> image.save("test.png", "PNG");
>>
>> //return a.exec();
>> }
>> ------------------------------------
>>
>> The following is the partial call stack:
>> QtCored4.dll!QBasicAtomicInt::ref() Line 257 + 0x8 bytes C++
>> QtGuid4.dll!QColormap::QColormap() Line 145 + 0x1d bytes C++
>> QtGuid4.dll!QColormap::instance(int __formal=-1) Line 141 + 0x13 bytes
>> C++
>> QtGuid4.dll!QNativeImage::systemFormat() Line 138 + 0xb bytes C++
>> QtGuid4.dll!QFontEngineWin::drawGDIGlyph(HFONT__ * font=0x2e0a0446,
>> unsigned int glyph=85, int margin=0, const QTransform & t={...}) Line
>> 1411 + 0x29 bytes C++
>> QtGuid4.dll!QFontEngineWin::alphaMapForGlyph(unsigned int glyph=85,
>> const QTransform & xform={...}) Line 1452 + 0x19 bytes C++
>> QtGuid4.dll!QImageTextureGlyphCache::fillTexture(const
>> QTextureGlyphCache::Coord & c={...}, unsigned int g=85) Line 227 +
>> 0x36 bytes C++
>> QtGuid4.dll!QTextureGlyphCache::populate(const QTextItemInt &
>> ti={...}, const QVarLengthArray<unsigned int,256> & glyphs={...},
>> const QVarLengthArray<QFixedPoint,256> & __formal={...}) Line 143
>> C++
>> QtGuid4.dll!QRasterPaintEngine::drawCachedGlyphs(const QPointF &
>> p={...}, const QTextItemInt & ti={...}) Line 2925 C++
>> QtGuid4.dll!QRasterPaintEngine::drawTextItem(const QPointF & p={...},
>> const QTextItem & textItem={...}) Line 3125 C++
>> QtGuid4.dll!QPainter::drawTextItem(const QPointF & p={...}, const
>> QTextItem & _ti={...}) Line 6123 C++
>> QtGuid4.dll!QPainter::drawText(const QPointF & p={...}, const QString
>> & str={...}, int tf=0, int justificationPadding=0) Line 5680 C++
>> QtGuid4.dll!QPainter::drawText(const QPointF & p={...}, const QString
>> & str={...}) Line 5618 C++
>> QtGuid4.dll!QPainter::drawText(int x=10, int y=100, const QString &
>> s={...}) Line 910 C++
>>
>>
>> The same code worked fine in Mac OS X. Any idea why it did not work on
>> windows? Did I miss something?
>>
>> I am using qt 4.5.1 on window with visual c++.
>>
>>
>> Thank you so much,
>>
>> Yanhao Zhu
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
More information about the Qt-interest-old
mailing list