Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPainter::begin: Paint device returned engine == 0, type: 2
QtWS25 Last Chance

QPainter::begin: Paint device returned engine == 0, type: 2

Scheduled Pinned Locked Moved General and Desktop
14 Posts 5 Posters 30.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ZapB
    wrote on last edited by
    #2

    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?

    Nokia Certified Qt Specialist
    Interested in hearing about Qt related work

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shiroki
      wrote on last edited by
      #3

      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.

      blog: http://www.cuteqt.com/blog
      bbs: http://www.cuteqt.com/bbs

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hsfougaris
        wrote on last edited by
        #4

        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_OBJECT

        public:
        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&#40;&#41;;
        

        }
        @

        This reproduces it for me.
        Thank you,
        Harry

        If you can't say what you mean, you'll never be able to mean what you say.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #5

          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?

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hsfougaris
            wrote on last edited by
            #6

            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.

            If you can't say what you mean, you'll never be able to mean what you say.

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #7

              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?

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hsfougaris
                wrote on last edited by
                #8

                I'm sorry I missed to specify it... 4.7.2

                If you can't say what you mean, you'll never be able to mean what you say.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #9

                  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.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hsfougaris
                    wrote on last edited by
                    #10

                    But my app isn't a 64 bit app...
                    Thankfully whatever it misses to paint is not visible, but it's still strange...

                    If you can't say what you mean, you'll never be able to mean what you say.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #11

                      But you are using 64 but win 7.
                      Ups sorry, my system is win XP, not win 7

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hsfougaris
                        wrote on last edited by
                        #12

                        So I guess this needs to be verified by someone running Win7/64 bit, to see if it can be reproduced...

                        If you can't say what you mean, you'll never be able to mean what you say.

                        1 Reply Last reply
                        0
                        • H Offline
                          H Offline
                          hsfougaris
                          wrote on last edited by
                          #13

                          can anyone running Win7/64 bit, please run the above code to see if it can be reproduce?

                          If you can't say what you mean, you'll never be able to mean what you say.

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            pinkieiknip
                            wrote on last edited by
                            #14

                            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.

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved