layout formatting

11 views
Skip to first unread message

bigt

unread,
Dec 8, 2012, 4:57:03 AM12/8/12
to qtalch...@googlegroups.com
I have two wishes:

1. when I show a list of customers and click on one I get the customer data at the left and a grid of orders on the right, as wanted.
However the window is split 50:50 between the customer details and the grid. I would like to control this so that I can use about 80% for the grid.

2. when I show a  grid, all of the columns have the same width. Since several of them are smallints while others are dates or money amounts, I want to reduce the size of some of the columns.


Any suggestions?

Joel B. Mohler

unread,
Dec 8, 2012, 8:04:20 PM12/8/12
to qtalch...@googlegroups.com
On 12/08/2012 04:57 AM, bigt wrote:
> I have two wishes:
>
> 1. when I show a list of customers and click on one I get the customer
> data at the left and a grid of orders on the right, as wanted.
> However the window is split 50:50 between the customer details and the
> grid. I would like to control this so that I can use about 80% for the
> grid.

This sounds like a Qt question more than a qtalchemy question. I think
the answer is to use QBoxLayout.setStretch. I find the documentation on
this to be unhelpful & vague. I think each widget in a layout has a
stretch factor and the extra space is split amongst the widgets using
the ratio of the respective stretch factors.

> 2. when I show a grid, all of the columns have the same width. Since
> several of them are smallints while others are dates or money amounts,
> I want to reduce the size of some of the columns.

The ModelColumn semi-internal class for each column of a *TableModel has
a width property. The actual width is computed by taking a ratio of the
given widths. I see that this only comes into affect when the
extensionId of TableView.setModel is not None. An example of this usage
is in https://bitbucket.org/jbmohler/pyhacc/src/tip/pyhacc/reports.py
where the setModel applies a model which is generated with ModelColumn
objects specific to each report. The updated documentation at
http://qtalchemy.org/docs/0.8.1/qtmodels.html may also help.

Joel
Reply all
Reply to author
Forward
0 new messages