I'm using Qt6.1 and I want send my widget's pixmap when it painted.
I have similar code:
void MyWidget::paintEvent(QPaintEvent*)
{
// static bool callGrab = true;
// m_callGrab initialize with true
if (m_callGrab)
{
m_callGrab = false;
auto pixmap = grab();
m_callGrab = true;
emit widgetRepainted(pixmap);
QPainter painter(this);
painter.drawPixmap(0, 0, pixmap);
painter.end();
return;
}
QPainter painter(this);
...
painter.end();
}
I know call grab()
in paintEvent()
will cause recursive so I use a variable to prevent it.
it works well, but I get "QWidget::repaint: Recursive repaint detected" in console. It's too lot and scrolls my debug information up.
I have tried add DEFINES += QT_NO_WARNING_OUTPUT
in my .pro file but it doesn't work.
I want to know whether can disable print the message in console.