Qt提示QPainter::begin: Paint device returned engine == 0, type:0/1/2/3...,type數值代表什麼
阿新 • • 發佈:2019-01-22
最近在做一個繪圖應用,經常會在除錯的時候看到QPainter::begin: Paint device returned engine == 0, type:1/2/3之類的警告。一直對type代表的具體內容不解,前幾天看了看QPainter的原始碼,恍然大悟~
d->engine = pd->paintEngine(); if (!d->engine) { qWarning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); return false; }
在這裡找到了這個警告的原型,然後跟蹤pd->devType()
int QImage::devType() const
{
return QInternal::Image;
}
看到了devType()返回的是QInternal::Image型別的列舉變數,再跟蹤QInternal::Image,在qnamespace裡,看到
都這裡,就一切都明瞭了class Q_CORE_EXPORT QInternal { public: enum PaintDeviceFlags { UnknownDevice = 0x00, Widget = 0x01, Pixmap = 0x02, Image = 0x03, Printer = 0x04, Picture = 0x05, Pbuffer = 0x06, // GL pbuffer FramebufferObject = 0x07, // GL framebuffer object CustomRaster = 0x08, MacQuartz = 0x09, PaintBuffer = 0x0a, OpenGL = 0x0b };