Unessesary repaint how to avoid
-
hello,
changing tab(QTabWidget) to another tab cause repaint view twice.
on that view i have OGLWidget with complicated charts and changing tab this is very horrible because of paint routine double called.i checked my application for any update, repaint occurences also all of events working fine except this above.
it will be gratefull to know how the problem should be resolved. -
you could try to resolve the issue manually:
attach yourself to the "currentChanged":http://qt-project.org/doc/qt-4.8/qtabwidget.html#currentChanged signal and set your GLWidget to visible while hiding the old widget in the connected slot.
IIRC, that's more or less the mechanics within the QTabWidget class itself, but there might be other stuff going on that causes the additional repaint. -
but ive aleardy had this signal connected and slot is empty and double repoaint still.
notice only that action causing twice paint. i really read my code carefully few times. i need info how to check what event causing this ot/and how to write some mechanizm to block update/paint at all and control thi only by own code. -
have you tried hiding/showing your GLWidget upon button press? That way, you could test whether repaint is called twice, too (which would make it a problem independent of the QTabWidget class).
Also (very important IMO): double check whether there are any unnecessary connections. Connecting to the same signal twice will result in a slot getting called twice.
If this doesn't help, I'm afraid the best way to track your problem is to put a breakpoint into your repaint method and analyze the stack trace to see where the second call originates from.
-
ok i did simple gdb session. here are result of breaking in paint when i changinh tab.
first paint :
#0 0x0000000000448d55 in oglPlotWidget::paintGL() ()
#1 0x00007ffff78f31a0 in QGLWidget::glDraw() ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#2 0x00007ffff78f2b39 in QGLWidget::paintEvent(QPaintEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#3 0x00007ffff6e2fc9c in QWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#4 0x00007ffff78f7d11 in QGLWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#5 0x00007ffff6ddf474 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#6 0x00007ffff6de42e1 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#7 0x00007ffff68aeafc in QCoreApplication::notifyInternal(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#8 0x00007ffff6e2cbd4 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#9 0x00007ffff6feb1d7 in QWidgetPrivate::repaint_sys(QRegion const&) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#10 0x00007ffff6e23354 in QWidgetPrivate::syncBackingStore() ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007ffff6e301ac in QWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#12 0x00007ffff78f7d11 in QGLWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#13 0x00007ffff6ddf474 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007ffff6de42e1 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#15 0x00007ffff68aeafc in QCoreApplication::notifyInternal(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#16 0x00007ffff68b251f in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#17 0x00007ffff68d9a73 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#18 0x00007ffff3935a5d in g_main_context_dispatch ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007ffff3936258 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007ffff3936429 in g_main_context_iteration ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007ffff68d9ed6 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#22 0x00007ffff6e8710e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#23 0x00007ffff68adcf2 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#24 0x00007ffff68adef7 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#25 0x00007ffff68b2789 in QCoreApplication::exec() ()second paint:
#0 0x0000000000448d55 in oglPlotWidget::paintGL() ()
#1 0x00007ffff78f31a0 in QGLWidget::glDraw() ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#2 0x00007ffff78f2b39 in QGLWidget::paintEvent(QPaintEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#3 0x00007ffff6e2fc9c in QWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#4 0x00007ffff78f7d11 in QGLWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtOpenGL.so.4
#5 0x00007ffff6ddf474 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#6 0x00007ffff6de42e1 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#7 0x00007ffff68aeafc in QCoreApplication::notifyInternal(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#8 0x00007ffff6e2cbd4 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#9 0x00007ffff6feb1d7 in QWidgetPrivate::repaint_sys(QRegion const&) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#10 0x00007ffff6e5db3a in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007ffff6e5ec7b in QApplication::x11ProcessEvent(_XEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#12 0x00007ffff6e874a2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#13 0x00007ffff3935a5d in g_main_context_dispatch ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#14 0x00007ffff3936258 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff3936429 in g_main_context_iteration ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff68d9ed6 in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#17 0x00007ffff6e8710e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#18 0x00007ffff68adcf2 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#19 0x00007ffff68adef7 in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#20 0x00007ffff68b2789 in QCoreApplication::exec() ()
from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#21 0x0000000000410c67 in main ()
and what now ? any idea ? -
i ve just resolved it using some workaroud :
@
bool oglPlotWidget::event(QEvent *e)
{ //12.77,18,24
if (e->type() == 18 || e->type() == 24 || e->type() == 77)
return false;
return QGLWidget::event(e);
}
@
may You tell me about some more elegance eoltion ?