0

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.

Cwift
  • 300
  • 1
  • 6
  • 1
    try add `QLoggingCategory::setFilterRules("*.debug=false");` – eyllanesc Jul 06 '21 at 03:41
  • @eyllanesc I tried add it in my constructor but it it still print "QWidget::repaint: Recursive repaint detected" and my qDebug() information doesn't print at all – Cwift Jul 06 '21 at 04:04
  • @eyllanesc I changed to `QLoggingCategory::setFilterRules("*.warning =false");` and it works. Thanks a lot – Cwift Jul 06 '21 at 04:22

0 Answers0