PDA

View Full Version : How to add a Button widget in a particular cell of QTableview without using delegate.



psarangi
3rd February 2014, 13:11
Hello,

I want to insert a pushButton in a particular cell of QTableView.
If I am using delegate, then its is replacing either colum, or row.
If i use delegate, Is there any thing, that we can set delegate in a particular cell

or

I want to know whether there is any other alternative to insert a button widget in a particular cell of QTableView.

Please suggest me.

Thanks ...

anda_skoa
3rd February 2014, 14:35
You can do that in your delegate by just passing to the base class implementation whenever you are not asked to handle the cell you want to do differently.

E.g. if you install a column delegate and you want that button in row 1, then check the index for row == 1, do your button, otherwise call into the delegate base class method.

Cheers,
_

psarangi
4th February 2014, 09:08
I have a table view, with 2 columns and few rows. I want a button delegate. If i am doing setItemDelegateForRow() the row is getting replaced by button delegate. But I dont want to replace my whole row. I want it to be drawn on given coordinates in the row withing replacing row content.


I am thinking to call paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) in my widget class through object of delegate class. because anyway the paint() is drawing the delegate as per coordinates. can i do so. If so, then how??



Thanks ..