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 removes last QImage data in next function call

QPainter removes last QImage data in next function call

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 478 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.
  • mmjvoxM Offline
    mmjvoxM Offline
    mmjvox
    wrote on last edited by mmjvox
    #1

    I defined a QList of QImage in a class header,

    (class.h)
    QList<QImage> imageList;

    and when call a function in that class it creates a new QImage and append that in imageList that i defined in header

    QImage printFace( 2100 , 2970 , QImage::Format_RGBA64_Premultiplied );
    imageList.append(printFace);

    and after that i create a QPainter on last QImage that i added in imageList

    QPainter painter(&imageList.last());

    and i draw a new image on painter

    painter.drawImage(50, 50 ,image1)

    Everything is right up to here.

    My problem is:
    when i call that function agane and draw new image with distance (free space) the last image i draw disappears.

    painter.drawImage(50, 200 ,image1)

    Note that i call that function in a loop in one clone (object) of that class and not a fresh object

    mrjjM 1 Reply Last reply
    1
    • mmjvoxM mmjvox

      I defined a QList of QImage in a class header,

      (class.h)
      QList<QImage> imageList;

      and when call a function in that class it creates a new QImage and append that in imageList that i defined in header

      QImage printFace( 2100 , 2970 , QImage::Format_RGBA64_Premultiplied );
      imageList.append(printFace);

      and after that i create a QPainter on last QImage that i added in imageList

      QPainter painter(&imageList.last());

      and i draw a new image on painter

      painter.drawImage(50, 50 ,image1)

      Everything is right up to here.

      My problem is:
      when i call that function agane and draw new image with distance (free space) the last image i draw disappears.

      painter.drawImage(50, 200 ,image1)

      Note that i call that function in a loop in one clone (object) of that class and not a fresh object

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mmjvox
      Hi
      Do you mean that the last image you draw on the QImage in the list, is
      overwritten when you draw on it again or in what way disappears ?

      mmjvoxM 1 Reply Last reply
      0
      • mrjjM mrjj

        @mmjvox
        Hi
        Do you mean that the last image you draw on the QImage in the list, is
        overwritten when you draw on it again or in what way disappears ?

        mmjvoxM Offline
        mmjvoxM Offline
        mmjvox
        wrote on last edited by
        #3

        @mrjj yes

        mrjjM 1 Reply Last reply
        0
        • mmjvoxM mmjvox

          @mrjj yes

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mmjvox
          That sounds odd as QPainter painter(&imageList.last());
          should not clear it or anything as far as i know.

          And you checked that it really is the same image as last time ?

          I see no fillRect or anything that should clear it so i think its somewhere else in the code
          than listed here.

          mmjvoxM 1 Reply Last reply
          1
          • mrjjM mrjj

            @mmjvox
            That sounds odd as QPainter painter(&imageList.last());
            should not clear it or anything as far as i know.

            And you checked that it really is the same image as last time ?

            I see no fillRect or anything that should clear it so i think its somewhere else in the code
            than listed here.

            mmjvoxM Offline
            mmjvoxM Offline
            mmjvox
            wrote on last edited by mmjvox
            #5

            @mrjj
            THANKS
            I see no fillRect or anything
            if you didnt say that, I never remembered that in my codes i used fillRect .
            i copied some code from my other project and i forgot to remove that
            and when i post my problem i only list Important parts or the parts I thought were wrong

            mrjjM 1 Reply Last reply
            2
            • mmjvoxM mmjvox

              @mrjj
              THANKS
              I see no fillRect or anything
              if you didnt say that, I never remembered that in my codes i used fillRect .
              i copied some code from my other project and i forgot to remove that
              and when i post my problem i only list Important parts or the parts I thought were wrong

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @mmjvox
              Oh thats great. Sometimes one can be lucky :)
              Well you did right. Its good to reduce the code to the parts that might matter.

              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