Pregunta

i try to check if QPixmap is initialized, when i try to check using :

QPixmap pix;

    if(pix.data_ptr())
    or
    if(pix != null)

where pix is member of QPixmap type .

all gives me :

Access violation reading location 0x0000000c.

how can i check in code if pix is null ?

¿Fue útil?

Solución 2

The only case when non-pointer QPixmap could be not initialized is when code like this is executed:

QPixmap getPixmap()
{
 // no return statement here
}

QPixmap pix = getPixmap();
// now pix is invalid but .isNull() will return false

I've had similar issues with no-initialized QStrings.

Otros consejos

Use the isNull() function,

if(!item->pix.isNull())
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top