Adding QPixmap to QLabel , flickering is happening.



  • Hi,

    I have the buffer, adding it to QPixmap to QLabel for showing images, continously.

    m_pixMap.loadFromData(QByteArray((char*)buf,size));
    m_pixMap1 = m_pixMap.scaled(label->width(),label->height(),Qt::IgnoreAspectRatio);
    label->setPixmap(m_pixMap1);

    How can i avoid filckering in QLabel,

    Thanks,


  • Lifetime Qt Champion

    Hi,

    What size of image ?
    How fast ?
    Where do they come from ?



  • @Pradeep-Kumar said in Adding QPixmap to QLabel , flickering is happening.:

    Hi,

    I have the buffer, adding it to QPixmap to QLabel for showing images, continously.

    m_pixMap.loadFromData(QByteArray((char*)buf,size));
    m_pixMap1 = m_pixMap.scaled(label->width(),label->height(),Qt::IgnoreAspectRatio);
    label->setPixmap(m_pixMap1);

    How can i avoid filckering in QLabel,

    Thanks,

    If you ignore the aspect ratio than this approach might be more usefull and without error:

    label->setScaledContents(true);
    label->setPixmap(m_pixMap.loadFromData(QByteArray((char*)buf,size)));
    


  • @J-Hilk

    I tried adding the

    label->setScaledContents(true);
    m_pixMap.loadFromData(QByteArray((char*)buf,size));
    label->setPixmap(m_pixMap);,

    still flickering is happening.

    Thanks,



  • @Pradeep-Kumar ok, we need some more information:
    You say, that you change the image continiously, how fast? Maybe iots to fast and the other Images are not painted properly resulting in flickering?



  • Images are coming from server, 15fps,

    Thanks,


  • Lifetime Qt Champion

    Again: what size are they ?
    Also, what format ?



  • Bitmap format.,
    and the size of image depends on the width, height of Widget.

    Thanks,


  • Lifetime Qt Champion

    Are you saying the image data your receive is already the size of your QLabel ?


Log in to reply