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: 1
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 19.6k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pufuzbufu
    wrote on last edited by
    #1

    Hi everyone. I have a simple QPainter program and I received this error when I'm trying to paint a widget.

    here is the code:
    @void MyGraphicsView::paintEvent(QPaintEvent *event)
    {
    QPainter p(this);
    p.setPen(Qt::red);
    p.drawText(10,10,"some text");

    }@

    here you can download a small sample project in case you wanna test it yourself: http://www.box.net/shared/yitvqvfcdv

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Didn't download the snippet, but if that class is a subclass of a QGraphicsView (and in general of a QAbstractScrollArea), you need to paint on the viewport().

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

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

        Try paint on the graphicsview'v viewport. GraphicsView will always paint its content to its viewport.

        1 Reply Last reply
        1
        • P Offline
          P Offline
          pufuzbufu
          wrote on last edited by
          #4

          ok. thanks. that worked. However now I'm facing a similar problem:

          I'm trying to render a QWebElement into a QWidget and I received the same error. here is my code:

          @QPainter painter(this->imageWidget);
          this->webElement.render(&painter);@

          I receive the following errors:

          bq. QPainter::begin: Paint device returned engine == 0, type: 1
          QPainter::setRenderHint: Painter must be active to set rendering hints
          QPainter::setBrush: Painter not active
          QPainter::pen: Painter not active
          QPainter::setPen: Painter not active
          QPainter::save: Painter not active
          QPainter::translate: Painter not active
          QPainter::save: Painter not active

          1 Reply Last reply
          0
          • A Offline
            A Offline
            astodolski
            wrote on last edited by
            #5

            [quote author="pufuzbufu" date="1307012108"]Hi everyone. I have a simple QPainter program and I received this error when I'm trying to paint a widget.

            here is the code:
            @void MyGraphicsView::paintEvent(QPaintEvent *event)
            {
            QPainter p(this);
            p.setPen(Qt::red);
            p.drawText(10,10,"some text");

            }@

            here you can download a small sample project in case you wanna test it yourself: http://www.box.net/shared/yitvqvfcdv[/quote]

            Downloaded, compiled, run. Draws nothing!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Why are you reviving a post that's more than 3 years old ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                astodolski
                wrote on last edited by
                #7

                [quote author="SGaist" date="1409084983"]Hi,

                Why are you reviving a post that's more than 3 years old ?[/quote]

                It's in the context of a problem I searched. Still the sample linked doesn't work. Change the forum engine so it can't be commented on (reviving) if that's causing a problem.

                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