Blog Image

Notes

Layouts Qt3 -> Qt4

Qt Posted on Mon, September 03, 2007 08:22:27

Converting layouts in Qt3 to Qt4 involves:

The old-style QLayout(QLayout* parent) needs to be replaced by a new
empty contructor and a subsequent parent->addLayout(child) statement.

Example Qt3:

QVBoxLayout *vbox = new QVBoxLayout ( this );
QHBoxLayout *box3 = new QVBoxLayout ( vbox );
QVBoxLayout *box4 = new QVBoxLayout ( box3 );
QVBoxLayout *box5 = new QVBoxLayout ( box3 );
QHBoxLayout *box6 = new QVBoxLayout ( vbox );

Ported to Qt4:

QVBoxLayout *vbox = new QVBoxLayout( this );
QHBoxLayout *box3 = new QHBoxLayout;
QVBoxLayout *box4 = new QVBoxLayout;
QVBoxLayout *box5 = new QVBoxLayout;
QHBoxLayout *box6 = new QHBoxLayout;

vbox->addLayout(box3);
box3->addLayout(box4);
box3->addLayout(box5);
vbox->addLayout(box6);



External library dependency

Qt Posted on Thu, August 30, 2007 08:19:49

When you change an external library, your Qt project is not recompiled. By default, qmake does not include external libraries in the dependencies for the final executable, because they are not part of the project itself. This can easily be solved by adding a forced dependency in the .pro file:

POST_TARGETDEPS += /libpath/libCAD.a



QVTKWidget BadWindow

Qt Posted on Thu, August 30, 2007 08:09:41

Using VTK (QVTKWidget) in combination with Qt 4.2.0 or Qt 4.2.1, which is included in the SuSe 10.2 distribution, can cause the following errors:

X Error: BadWindow (invalid Window parameter) 3
Major opcode: 3 (X_GetWindowAttributes)
Resource id: 0x0
X Error: BadValue (integer parameter out of range for operation) 2
Major opcode: 1 (X_CreateWindow)
Resource id: 0x0
X Error: BadWindow (invalid Window parameter) 3
Major opcode: 20 (X_GetProperty)
Resource id: 0x0
X Error: BadWindow (invalid Window parameter) 3
Major opcode: 3 (X_GetWindowAttributes)
Resource id: 0x3c00002
Segmentation fault

This is a bug introduced in Qt 4.2.0 where they delete all descending underlying windows when reparenting a widget. This is fixed in Qt 4.2.2. More information here.