Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Chaining painting to images [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Chaining painting to images [SOLVED]

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.9k 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.
  • M Offline
    M Offline
    minimoog77
    wrote on last edited by
    #1

    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 *)
    {
    painter->drawImage(m_myImage);
    }

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      The code you show looks alright to me.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        minimoog77
        wrote on last edited by
        #3

        Then why I am getting the error?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            minimoog77
            wrote on last edited by
            #5

            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.

            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