QPainter::begin: Paint device returned engine == 0, type: 2
-
This is a long shot given the nature of my problem, but can anyone here help me debug this message I'm seeing in my debug output?
QPainter::begin: Paint device returned engine == 0, type: 2It occurs when I add about 10 columns with checkboxes to a QTreeView and QTreeWidget, and I hover over the columns or resize them.
I tried first with a QTreeWidget and creating everything manually (like calling setItemWidget(..) with a QCheckBox as an argument.
I then tried it with a QStandardItemModel by adding QStandardItems with setCheckable set to true.I get the exact same behaviour: a few messages like that every now and then.
The actual functionality of the form and control don't seem to be affected; Should I just ignore it?
I am running under Windows 7/64 bit with QtCreator 2.1 (my app is not 64 bit).Thank you,
Harry Sfougaris -
Ok, here it is.
Since I can't attach the project:
It's a simple project, the one creator generates.
I added in designer a treeview to the MainWindow and laid it out vertically.mainwindow.h
@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QStandardItemModel>namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();private:
Ui::MainWindow *ui;
void prepareDataSrc();
QStandardItemModel *dataSrc;
};#endif // MAINWINDOW_H
@mainwindow.cpp:
@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QStandardItem>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
dataSrc = new QStandardItemModel();
prepareDataSrc();
ui->tVw->setModel(dataSrc);
ui->tVw->expandAll();
ui->tVw->setColumnWidth(0, 250);
}void MainWindow::prepareDataSrc(){
QStringList hdr;
hdr << "Descr" << "Col0" << "Col1" << "Col2" << "Col3" << "Col4" << "Col5" << "Col6" << "Col7" << "Col8" << "Col9";dataSrc->setHorizontalHeaderLabels(hdr); for (int i = 0; i < 100; i++) { QList<QStandardItem*> iRow; QStandardItem *iDescr = new QStandardItem(); iDescr->setText( QString("Item #%1").arg(i)); iDescr->setEditable(false); iDescr->setData(i, Qt::UserRole); iRow << iDescr; for (int i2 = 0; i2 < 10; i2++) { QStandardItem *_i = new QStandardItem(); _i->setCheckable(true); _i->setEditable(false); _i->setTristate(false); _i->setData(i2, Qt::UserRole); _i->setCheckState(Qt::Checked); iRow << _i; } if (iDescr->hasChildren()) { QFont f = iDescr->font(); f.setBold(true); iDescr->setFont(f); } dataSrc->invisibleRootItem()->appendRow(iRow); }
}
MainWindow::~MainWindow()
{
delete ui;
}
@main.cpp:
@
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QTextCodec>int main(int argc, char *argv[])
{
QString c = "UTF-8";
QTextCodec::setCodecForTr(QTextCodec::codecForName(c.toLatin1()));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName(c.toLatin1()));
QTextCodec::setCodecForLocale(QTextCodec::codecForName(c.toLatin1()));QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();
}
@This reproduces it for me.
Thank you,
Harry -
I have tried it here (Gentoo Linux, Qt 4.7.2, raster paint engine) and I get no warnings at all from your example.
What version of Qt are you using? Did you build it yourself or is it a pre-compiled binary distribution of Qt? What paint engine are you using?
-
I am running under Windows 7/64 bit with QtCreator 2.1.
I am using the pre-compiled binary distribution from Qt.Paint engine? I don't know what you mean... I haven't done anything to explicitly use a particular engine.
-
I'm sorry I missed to specify it... 4.7.2
-
Hi,
on windows using MSVS 2008 and pre build binaries, on Win7 32 bit, I can't reproduce this behavior.
But if you look at the Qt code it is printed out, when@
bool QPainter::begin(QPaintDevice *pd)
{
....d->engine = pd->paintEngine(); if (!d->engine) { qWarning("QPainter::begin: Paint device returned engine == 0, type: %d", pd->devType()); return false; } ....
@
It could perhaps be a 64 bit issue.
-
But my app isn't a 64 bit app...
Thankfully whatever it misses to paint is not visible, but it's still strange... -
So I guess this needs to be verified by someone running Win7/64 bit, to see if it can be reproduced...
-
can anyone running Win7/64 bit, please run the above code to see if it can be reproduce?
-
Just tried this with W7/64 on Qt 4.8.3 MinGW distribution, no messages or warnings running this code. Also tried 4.7.4 MinGW distribution, no warnings there. It shows the items properly, the checkboxes and list also behave properly.
-
I know, it's a very long time, but still actual for me (just found this thread in Google).
So, my suggestion would be to set your own message handler (using qInstallMessageHandler) and inside of this handler do something:
if (msg.indexOf("QPainter::begin: Paint device returned engine") == 0) { ; // set breakpoint here! }
And then see a back trace down to the line in your code that caused it.