PDA

View Full Version : resizing events of a custom widget in a layout



Rooster
15th February 2008, 04:24
I have created a custom widget that has things different graphs that are placed on it by a QPainter. (Not sure if this info is needed or not). When I start the program everything comes up fine, but when I change the size of the window the custom widget just stays the same size and everything around it is distorted.

The custom widget is in a vertical layout and the custom widget is a public QWidget.

jpn
15th February 2008, 07:02
Use layouts (http://doc.trolltech.com/3.3/layout.html).

Rooster
15th February 2008, 16:10
Use layouts (http://doc.trolltech.com/3.3/layout.html).

Yeah,

I am using layouts. That is why I am having issues and don't know what to do. Is there a flag that I have to set or something. Again the issue is when I resize the window my custom widget stays the same size.

jpn
15th February 2008, 16:14
Sounds like you're missing the top level layout. Even if child widgets are laid into a layout no layout might be installed on the window itself.

Rooster
15th February 2008, 16:51
Sounds like you're missing the top level layout. Even if child widgets are laid into a layout no layout might be installed on the window itself.

I now have a top level layout and I am still having problems. The custom QPainter widget that I have created is a QWidget. The other custom Widget that I am add it to is a QMainWindow. Could this be a problem? If I change t to a QFrame do you think I will work better.

This is the first time I have had to do something like this and am really getting frustrated at it.

jpn
15th February 2008, 17:03
The custom QPainter widget that I have created is a QWidget.
What? QPainter is a QWidget? How come? I'm confused. Usually you create a QPainter on a paint device (eg. QWidget) to paint on it...

Rooster
16th February 2008, 00:02
Ok, never mind that.

Right now when I run the program I get the error

QLayout "unnamed" added to protein "unnamed", which already has a layout

is there a reason that this is happening.

jpn
16th February 2008, 10:52
Right now when I run the program I get the error

QLayout "unnamed" added to protein "unnamed", which already has a layout

is there a reason that this is happening.
In Qt 3 layouts are installed by passing the parent widget to QLayout constructor. Most likely you pass same widget by accident to two different layouts. Thus, the latter attempt gives you a warning because you can't install two layouts on same widget.