Rendering in QWidget using QPainter



  • Hi,

    We have the widget , were we are painting the live streams(bitmap) on to the QWidget, and the bitmap is of high quality image 720p , do we need any special functions to render on to the QWIdget via QPainter?.

    Thanks,


  • Moderators

    @Pradeep-Kumar Not that I know. You just pass your widget to QPainter constructor and then use that painter to paint. What special functions do you mean?



  • Hi,

    We have pixel data of bitmap and header , and we dont have file header for the bitmap .

    Sample code :

    m_data = bitmap;  // without file header
    
      image->loadFromData(m_data);
    
       QRect rect(m_widget->x(),m_widget->y(),m_widget->width(),m_widget->height());
    
    
    
       QPainter painter(this);
       painter.drawImage(rect,*image,image->rect());
    

    , we have a buffer without file header can we paint?.
    Any alternate api to load?.

    from docs

    bool QImage::loadFromData(const uchar * data, int len, const char * format = 0)
    
    Loads an image from the first len bytes of the given binary data. Returns true if the image was successfully loaded; otherwise invalidates the image and returns false.
    
    The loader attempts to read the image using the specified format, e.g., PNG or JPG. If format is not specified (which is the default), the loader probes the file for a header to guess the file format.
    

    Thanks,


  • Lifetime Qt Champion

    Hi,

    What do you mean by bitmap ? RGB32 raw data ?


  • Moderators

    @Pradeep-Kumar As the documentation says you can specify the format. Do you? Does loadFromData() return true or false? Did you actually try before asking?


Log in to reply
 

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