[Interest] extending qtableview with button bar with inheritance

Mojmír Svoboda mojmir.svoboda at bistudio.com
Wed Apr 16 16:40:18 CEST 2014


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