[Interest] extending qtableview with button bar with inheritance
Tony Rietwyk
tony at rightsoft.com.au
Wed Apr 30 17:58:06 CEST 2014
Hi Mojmir,
My understanding is that qtableView uses a (private) layout to manage the
qheaderview, scroll bars, etc. Unfortunately, the docs don't spell this
out.
One workaround is to
- set the top content margin of the viewport to the height of your button
bar. (setContentMargins)
- create the button bar owned by the viewport, and positioned at (0, 0).
- listen for viewport resize events and adjust your button bar width.
(installEventFilter)
Hope that helps,
Tony
> Sent: Thursday, 17 April 2014 12:40 AM
>
> Hello,
>
> how to extend a qtableview with a custom button bar? so that the button
> bar is above the qtableview.
>
> i tried something like this, but it does not feel right:
> struct MyTableView : QTableView
> and in the constructor do
> 1) layout = new QVBoxLayout
> 2) setLayout(layout)
> 3) mybuttonbar = new ...
> 4) layout->insertWidget(0, mybuttonbar)
>
> but it behaves in weird ways (endless loop in some parent detection,
stealing
> keypresses from qtableview)... so i am not sure that is the way to do it.
>
> Another possibility is to create completely different class and using
> composition instead of inheritance. This works well, but for some reason i
> wanted the IS-A relationship above (i do not remember why now).
>
> How would you do that, please?
>
> Best regards,
> Mojmir
More information about the Interest
mailing list