Solved How to use QPainter in sub-thread ?
-
I have a question about QPainter. As we know :
- QPainter could only be used in a paintEvent();
- A paintEvent() is a over-ride function that only a QWidget has.
- A QWidget is a UI member, and qt's ui could only be in main thread.
So , does that mean u could only use QPainter in main thread ?? How could I draw a QImage in backstage ?
-
@MartinChan-0 said in How to use QPainter in sub-thread ?:
QPainter could only be used in a paintEvent();
This is a wrong assumption. See documentation (http://doc.qt.io/qt-5/qpainter.html):
"Warning: When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent()."If you want to paint on a QImage it should work in a thread.