Results 1 to 10 of 10

Thread: Adding button to QTableview .

  1. #1
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Adding button to QTableview .

    I have created one table by using QTableview and QAbstractTableModel .
    In one of the cell i want to add one help button (right corner of that cell ).

    Is there any way to achieve the above one ?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding button to QTableview .

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Adding button to QTableview .

    can you please give a small example on this ?

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding button to QTableview .

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Adding button to QTableview .

    but through QItemDelegate we can only display the widget during editing the cell..
    Is there any way to display it permanently ?

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding button to QTableview .

    Well, you can use QAbstractItemView::openPersistentEditor, but it can "slow down" your view if there are a lot of data.
    I would suggest to grab an editor using QPixmap::grabWidget or even better to render it using QWidget::render in the item's delegate QItemDelegate::paint method.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Adding button to QTableview .

    thank you .. i got the concept ..But when i am using the delegate , that delegate overlapes on the existing data ..
    can you please give any idea on this ?

  8. #8
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding button to QTableview .

    Hi,

    I am trying to "to render it using QWidget::render in the item's delegate QItemDelegate:aint method".

    I took the Qt example "SpinBoxDelegate" and I try to display a QToolButton :

    Qt Code:
    1. void SpinBoxDelegate::paint(QPainter *painter,
    2. const QStyleOptionViewItem &option,
    3. const QModelIndex &index) const
    4. {
    5. if (index.column() == 1)
    6. {
    7. QToolButton* widget = new QToolButton();
    8. widget->setText("Click me");
    9. widget->render( painter );
    10. }
    11. else
    12. {
    13. QItemDelegate::paint(painter, option, index);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    But nothing is displayed...

    How am I supposed to create the widget ?

  9. #9
    Join Date
    Oct 2013
    Posts
    3
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Windows

    Default Re: Adding button to QTableview .

    Hello,
    i have similar issue ( displaying button in tableview), can you pls let me know how you fixed this ?
    Thank you.

  10. #10
    Join Date
    Nov 2012
    Posts
    9
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding button to QTableview .

    Just create one button image over the place you want to put button and add an event to that image which works like a button .

Similar Threads

  1. adding image and text both to a push button
    By Charvi in forum Qt Programming
    Replies: 5
    Last Post: 3rd August 2012, 08:44
  2. Adding a OK and Cancel button to QTableview
    By rex in forum Qt Programming
    Replies: 0
    Last Post: 24th July 2011, 17:32
  3. [QTabWidget] Adding additional button
    By winuser in forum Newbie
    Replies: 1
    Last Post: 3rd December 2010, 12:56
  4. Adding some padding to a button
    By scarleton in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2010, 15:18
  5. Adding a button in the header of a QTreeWidget
    By ioannis in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2008, 18:06

Tags for this Thread

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.