Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QPainter removes last QImage data in next function call



  • 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


  • Lifetime Qt Champion

    @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 ?



  • @mrjj yes


  • Lifetime Qt Champion

    @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.



  • @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


  • Lifetime Qt Champion

    @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.


Log in to reply