Hello all,
A simple problem for anyone who know Qt, I'm very new to Qt and GUI programming in general.

I’m on a linux platform and using Qtcreator.

I have a window (see here for a screen shot).

I wish to have two "sub regions" (incorrect terminology I’m sure) within the window and then create a QPainter object within each of those regions. Relative to the screenshot of my window I would like a two horizontal boxes / regions to the RHS and then be able to draw my objects within these.

I thought about just creating two artificial offsets and working from the main window's origin and then drawing my objects with a QPaint object(s) but there must be a better solution to this.

Can someone point me in the correct direction and maybe to a reference with some simple examples of what I’m trying to achieve.

Many Thanks

You can use the "Widget" object, and a lay out. It's kind of hard to explain how to do this, but it is easy.

Say you have a main window. You can create a Widget that you put on it. Then, create a second Widget that you put on the main window also. Then, right click on the "MainWindow" (in the Object Inspector) and go to the "Lay out" menu and select the "Lay out vertically". This will cause the two Widgets to take half of the main window each, i.e., one filling the upper half, the other filling the lower half. At this point, you can set fixed sizes or whatever else if you want to change how the two Widgets split the main window. Finally, you can add whatever else you want in either Widget, like a QPaint object or whatever else.

You can also create many other kinds of lay outs, and they are very useful for placing different objects in different places. It is also good for automatically adapting the sizes of things when the main window is resized and stuff.

You could create a form/grid layout as mike_2000_17 suggested, where form stands for a simple form with 2 columns and many rows, and grid with many rows/columns. See the attachement below:

Just quick thanks for the lead, and taking time to reply.
No time tonight to check it out but I'll try tomorrow and report back with any further prblems.


This article has been dead for over six months. Start a new discussion instead.