Results 1 to 3 of 3

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

  1. #1
    Join Date
    Nov 2013
    Posts
    12
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default How to add a Button widget in a particular cell of QTableview without using delegate.

    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 ...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to add a Button widget in a particular cell of QTableview without using deleg

    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,
    _

  3. #3
    Join Date
    Nov 2013
    Posts
    12
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to add a Button widget in a particular cell of QTableview without using deleg

    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 ..

Similar Threads

  1. QTableView tab focus on cell widget
    By hispeedsurfer in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2013, 14:30
  2. Replies: 8
    Last Post: 9th August 2012, 08:14
  3. Inserting a Custom Widget inside a QTableView Cell
    By fruzzo in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2012, 21:38
  4. Replies: 2
    Last Post: 18th July 2011, 00:25
  5. Replies: 3
    Last Post: 5th April 2010, 21:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.