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. QGraphicsView print error : "QPainter::begin: Paint device returned engine == 0, type: 1"
Forum Updated to NodeBB v4.3 + New Features

QGraphicsView print error : "QPainter::begin: Paint device returned engine == 0, type: 1"

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k 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.
  • V Offline
    V Offline
    Vetryaspa
    wrote on last edited by
    #1

    @
    class MappaRegioni : public QGraphicsView

    { [...] }

    bool MappaRegioni::viewportEvent(QEvent *event)
    {

    QPainter painter(this);
    QImage *euro = new QImage(QSize(35,29),QImage::Format_ARGB32_Premultiplied);
    QString euroName(":/new/Generale/Grafiche/Varie/IconAddress.png");
    euro->load(euroName);
    painter.drawImage(QPoint(150,150) ,*euro);
    

    }

    @

    Why return this error? I have read some post and i have found that the viewportEvent() method paint!!

    What my error is?

    Regards

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vetryaspa
      wrote on last edited by
      #2

      No body can help me?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dhaumann
        wrote on last edited by
        #3

        In general, you should, and in fact mostly cannot paint outside paint events (if you really really need this, you have to enable painting outside of the paintEvent by setting the flag Qt::WA_PaintOutsidePaintEvent. This is highly discouraged, though!).

        If you want to paint in the QGraphiscView, You should reimplement QGraphicsView::paintEvent().

        However, the correct solution is to use one of the two dedicated functions in QGraphicsView that allow you to paint behind all items in the background, or as overlay on top of all items:
        virtual void drawBackground ( QPainter * painter, const QRectF & rect )
        virtual void drawForeground ( QPainter * painter, const QRectF & rect )

        Please look in the Qt Assistant documentation in QGraphicsView for further details.

        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