QTableView issues
Andreas Pakulat
apaku at gmx.de
Sun Dec 16 05:45:10 UTC 2007
On 15.12.07 21:50:23, Vladimir Prus wrote:
>
> Looking at current breakpoint windget, I see that the table
> header does not use 100% of width -- in fact, the columns are
> so narrow that captions itself are not readable.
Easily fixable: QHeaderView allows to set a resize-strategy for each
column, usually ResizeToContents is what you want.
> Furthermore, the first column "Enable/Disable" is edited using
> combobox with "True" and "False" as values, and unless I double click
> it, no value is shown at all.
Note: I haven't yet looked at the code or even the new GUI.
That sounds like a bug. Which reminds me: Qt4.3 has this nice bug for
views where you have to click the checkbox a little to the left of the
actual drawing as the clickable area is at the wrong spot. Its fixed in
4.4 and eventually also in 4.3 (didn't follow the tracker too closely).
> 1. I want the "Enable" column to be combobox. I've tried
> to make the data method of the model return Qt::Unchecked/Qt::Checked,
> which almost worked. Now, the cell has a checkbox, but Qt
> draws an empty area with dotted border right to checkbox. How do
> I tell Qt there's nothing but checkbox?
Don't return anything for the display role or any other role.
> 2. I want most of columns to be wide enough to either
> display the header, or N characters. How do I compute this
> number, taking into account any padding QItemDelete would put?
See above. There's no easy way to define a column width that is resized
to its contents, but only until its n characters wide. And I think thats
not a problem, how do you know that N characters doesn't make the whole
thing too wide for your users monitor. I think its ok to have them
ResizeToContents or if they might be too wide, have them set to Stretch,
which makes them expand until the full visible width is shown - without
adding a scrollbar.
> 3. I want one column ('Location') to take all extra available width,
> but still allow to resize other columns. While QHeaderView::Stretch
> allows me to make the column wide enough, it makes subsequence
> columns not resizeable (actually they are resizeable but only if I drag
> the separator to the *right* of the column -- which looks more like
> a bug than a desired behaviour).
Generally there's only two modes in QHeaderView: Computer-sized columns,
or manually sized columns. If you want a column to stretch, but also
want it to be user-resizeable, you're going to have to compute the
remaining size of the tableview and set its size once. This of course
breaks as soon as you start resizing the mainwindow, then you'd have to
hookup an event filter and you'd also have to hookup something which
tells you that the column was resized by the user. Neither of that
sounds like a very good idea to me, too much work for too little gain -
IMHO.
Andreas
--
You will be called upon to help a friend in trouble.
More information about the KDevelop-devel
mailing list