c++ - How to dynamically resize a QImage used in a QLabel/QVBoxLayout/QWidget -
i have derived class (from qwidget) uses qvboxlayout 2 items, both of qlabel. top qlabel used display video stream , bottom qlabel use status line. 1 of examples in qt documentation.
capturewin::capturewin() { qvboxlayout *vbox = new qvboxlayout(this); vbox->setcontentsmargins(qmargins(8, 8, 8, 5)); m_plabel = new qlabel(); m_pmessage = new qlabel("no frame"); vbox->addwidget(m_plabel); vbox->addwidget(m_pmessage); } void capturewin::setimage(const qimage &image, const qstring &status) { m_plabel->setpixmap(qpixmap::fromimage(image)); m_pmessage->settext(status); }
this working fine, program captures video shared memory segment (generated different process) , video displayed in window.
however, video image size can change, trying extend change different size videos dynamically. shared memory header gives information image sizes. can emit signals when size changes.
currently in slot delete qimage obj, create new qimage obj new size.like this:
void dialog::updatepicturesize() { delete m_pcaptureimage; m_pcaptureimage = new qimage(m_npicturewidth, m_npictureheight, qimage::format_rgb32); m_pcapturewin->repaint(); m_pcapturewin->show(); }
as said works fine, capturewin not resize, qimage. when go large video size small video size basic window not change left large white window small image inside.
the more think this, think poor design because qvboxlayout, has reference qimage, not know has changed.
so, proper way have capturewin obj resize accommodate new qimage size?
thanks,
-andres
Comments
Post a Comment