PDA

View Full Version : QWidget::paintEvent() called repeatedly when using static Qt libraries



redBeard
16th April 2011, 00:38
Environment: Qt 4.7.0. Windows Vista

I've been developing an application with custom graphics (Qt primitives- n OpenGL-based). The main display window extends QMainWindow.

For the QMainWindow::centralWidget I subclassed QWidget and added that to the QMainWindow. The centralWidget uses a QBoxLayout with vertical orientation.

I then add a number of other custom QWidgets and QGLWidgets to this central widget. All of them, including the central widget do a 'setAutoFillBackground(true);' when created. This allows me to control the update of the widgets using a timer (e.g., connect(panelUpdateTimer, SIGNAL(timeout()), centralWidget, SLOT(repaint())) ; ).

This all works nicely when I use the distributed Qt libraries on Windows Vista and using the Qt DLLs.

However, I want to release my application with everything compiled into a nice tight package.

I created a 'static' version of the Qt libraries using the following 'configure' line:


configure -static -debug -opensource -qt-sql-mysql
-qt-sql-odbc -graphicssystem runtime -qt-style-windowsvista

When I build my application against that structure, the centralWidget : : paintEvent() method is called continuously and not under my control. The event type (parameter) is a 'QEvent::Paint'.

Am I missing something with the way I built the Qt libraries or is this a known bug or?

Thanks.

Added after 1 40 minutes:

Figgered this out.....

I re-built my application using the main Qt (DLL-based) structure and the problem went away (the centralWidget : : paintEvent() method is only called under my control, either via the timer or window resizing events).

I then copied my application back to my Linux workstation and it works as expected there. So I was building confidence that I hadn't introduced a bug in my code and concentrated more on the Qt structure I built.

Notice I build my Qt static libraries with '-graphicssystem runtime'. The Qt documentation doesn't really say what is used if I don't specify a QT_GRAPHICSSYSTEM value at runtime. The application is displayed so something is used, right?!?

Well, I set QT_GRAPHICSSYSTEM to 'raster' and fired it back up. Behaves as expected. I also tried 'opengl' and 'native' and it also behaves as expected.

Whew.