Using QImage pointer from a QPainter method



  • Hi,

    I have to code a method just to display an image. No big deal at all, except that for some reason out of my control, I have to receive the image as a pointer.

    void MyClass::paintImage(const QPoint &point, QImage *image) 
    {    
        QPainter painter;
        painter.drawImage(point, ______________ );
    }
    

    Understanding that the QPainter::drawImage() method requires a non-pointer variable by definition:

    void QPainter::drawImage(const QPointF &point, const QImage &image)
    

    How can I make a reference of the image pointer from this method? Is it possible?
    Thanks.



  • Just dereference it after checking for null

    void MyClass::paintImage(const QPoint &point, QImage *image) 
    {    
    if(image){
        QPainter painter;
        painter.drawImage(point, *image);
    }
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.