[Qt-interest] Change layout in subclass of standard widget ?
Stephen Collyer
scollyer at netspinner.co.uk
Tue May 26 16:58:30 CEST 2009
2009/5/26 Andreas Pakulat <apaku at gmx.de>
> On 26.05.09 10:52:37, Stephen Collyer wrote:
> >
> > This doesn't seem entirely correct to me. All classes derived from
> QWidget
> > support setLayout() so it would seem possible, at least in principle,
> > to change the layout of a standard widget. The QWidget docs give an
> > example of this being done:
> >
> > http://doc.qtsoftware.com/4.5/qwidget.html#setLayout
> >
> > I suspect I'm merely doing it incorrectly.
>
> No, what you're missing is that a QTableView doesn't actually have an
> internal layout. It is completely drawing its scrollarea itself. So if you
> start to set layouts on this widget, you're breaking tons of assumptions
> done when the QTableView code was written.
>
OK. This is a good point. However, how does one know in advance if
any given widget uses an internal layout ? Is this documented ?
> IMHO you're wrong here, because your widget is not a tableview anymore. Its
> a tableview+something extra. So in fact the proper relation of your widget
> to the tableview should be a has-A relation, not is-A.
>
I would have to disagree. If we followed your argument, then no derived
class could contain any additional members, since then it would be a "class
+ something extra".
Anyway, it looks like I'll have to go for composition, given that QTableView
has no layout. That seems like a pity.
--
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090526/9a24e507/attachment.html
More information about the Qt-interest-old
mailing list