QPainter::begin: Paint device returned engine == 0, type: 2
-
wrote on 28 Mar 2011, 06:49 last edited by
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 -
wrote on 28 Mar 2011, 13:21 last edited by
Have you tried debugging into Qt to see what causes this message (you'll need a debug build of Qt)? Can you provide a small compilable example that reproduces this please?
-
wrote on 28 Mar 2011, 14:13 last edited by
I agree with ZapB. You have to provide a compilable example or a backtrace for this issue. without seeing the code, it's impossible to tell what the problem is.
-
wrote on 29 Mar 2011, 06:48 last edited by
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 -
wrote on 29 Mar 2011, 08:16 last edited by
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?
-
wrote on 29 Mar 2011, 08:38 last edited by
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.
-
wrote on 29 Mar 2011, 08:44 last edited by
OK so you are likely using the raster paint engine then as that is the default on Windows.
Which version of Qt though? 4.7.0, 4.7.1, 4.7.2? Something older?
-
wrote on 29 Mar 2011, 08:47 last edited by
I'm sorry I missed to specify it... 4.7.2
-
wrote on 29 Mar 2011, 09:02 last edited by
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.
-
wrote on 29 Mar 2011, 09:09 last edited by
But my app isn't a 64 bit app...
Thankfully whatever it misses to paint is not visible, but it's still strange... -
wrote on 29 Mar 2011, 09:20 last edited by
But you are using 64 but win 7.
Ups sorry, my system is win XP, not win 7 -
wrote on 29 Mar 2011, 09:27 last edited by
So I guess this needs to be verified by someone running Win7/64 bit, to see if it can be reproduced...
-
wrote on 1 Apr 2011, 01:04 last edited by
can anyone running Win7/64 bit, please run the above code to see if it can be reproduce?
-
wrote on 28 Dec 2012, 13:27 last edited by
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.