[SOLVED] Use QScollArea & QLabel to display image
-
I guess the paint event is not blocked
so it happens anyway.
Since the scrollbars tells scroll area to scroll and it then the label repaints itself.If you build your own widget and draw the image in the paintevent, it would be
easier to make sure its not painting when being updated, I guess.Do you really need to scroll the image at 400 fps ?
Its like preview of the stream? -
@mrjj Yes. This window is for preview of the stream. The stream is received from a high speed camera, its feature is high speed, up to 400 fps - -!
I will think about building my own widget. Could you please show me some examples, if convenient.
Thank you for your patience. :) -
@sheeley
sketch code, fix to compile.
Then if you lock the image when you set it and unlock
when finished. and in paint check if ok to paint it.
Something like that.class ImgPreview : public QWidget { Q_OBJECT public: ImgPreview(QWidget *parent = 0) : QWidget(parent) {}; protected: void paintEvent(QPaintEvent *event) { QPainter p ( this ); if (ok_to_access_img) p.drawImage(image); } private: void setImagePixel() {} QImage image; };
-
@mrjj OK. Thank you. If any questions, I'll keep in touch with you later.
-
@mrjj Hi, I found some issues.
If I overwrite the paint function, when I drag the scrollbars, the window will stay unchanged. This will lead to an un-continuous feeling, yes? -
@sheeley
hi
set you widget , minimum size to the image size to it will reflect the image. then
scrolling works like with the QLabel and you can control when its safe to repaint. -
@mrjj Hi.
I'm very excited now. I fixed it with defining a new signal and slot to do the refreshing work. The code is as follow: https://gist.github.com/tianshilei1992/fd76520532127deb28de
Done! The application won't crash, anymore! :)
Thank you for your patience yesterday. -
@sheeley
Good work!
Thank you for update. -
Hi,
I followed your link but it is not available. I am interested in how you solved the problem. I am also trying to display video stream on QLabel with high framerate and large size of image. However, I suffer from screen tearing effect.
Thanks. -
@phnhung98 said in [SOLVED] Use QScollArea & QLabel to display image:
Hi,
I followed your link but it is not available. I am interested in how you solved the problem. I am also trying to display video stream on QLabel with high framerate and large size of image. However, I suffer from screen tearing effect.
Thanks.Hi and welcome to devnet,
Please define high speed and large size.