QPainter::setBrush: Painter not active
时间: 2023-12-11 14:10:34 浏览: 168
QPainter:CPP实习生,Sotfware,Painter
This error message typically appears when you attempt to set the brush property of a QPainter object that is not currently active.
A QPainter object must be activated before it can be used to draw on a widget or other paint device. To activate a QPainter object, you can call the begin() method and pass in a pointer to the paint device you want to draw on.
For example, if you want to draw on a QWidget named myWidget, you could activate a QPainter object like this:
QPainter painter;
painter.begin(myWidget);
Once the QPainter object is active, you can set the brush property using the setBrush() method. However, if you attempt to call setBrush() on an inactive QPainter object, you will see the "Painter not active" error message.
To fix this error, make sure that your QPainter object is active before attempting to set any of its properties. If you're still having trouble, double-check that you're passing in a valid paint device to the begin() method.
阅读全文