Qt World Summit: Register Today!

Chaining painting to images [SOLVED]

  • Maybe this post is another forum, but anyway it's related to QML.

    I have this type of problem:

    @void MyDeclarativeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)

    void MyDeclarativeItem::somethingHappened()
    QPainter painterToImage(&m_myImage);
    //draw something to image

    Which of course fails, with error when construncting painterToImage 'QPainter::begin: A paint device can only be painted by one painter at a time.'.

    Someone knows how to paint to image, and then that painted image to be used in painter of the QDeclarativeItem? Or am I missing something?

  • The code you show looks alright to me.

  • Then why I am getting the error?

  • Based on the tiny sample of code you posted, that is impossible to tell. Perhaps there is another painter still open on the image somehow?

  • Well, it doesn't depend if I paint or not in paint() method. Which is more strange.

    All I have done is this

    @m_myImage = QImage(w, h, QImage::Format_ARGB32_Premutliplied);
    QPainter myImagePainter(&m_myImage);

    Nothing more. And I am still getting the same error.

Log in to reply