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


  • 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
       QRect rect(m_widget->x(),m_widget->y(),m_widget->width(),m_widget->height());
       QPainter painter(this);

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


  • Lifetime Qt Champion


    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.