Results 1 to 2 of 2

Thread: Editable table header

  1. #1
    Join Date
    Jun 2006
    Posts
    6
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Editable table header

    I want to doubleclick on a header in a QTableWidget and open an editor to change the text. Having trouble with the MVC paradigm. I created my own QHeaderView, and overrode mousedoubleclickevent(). Now I don't know what to do

    Qt Code:
    1. class RowHeaderView : public QHeaderView
    2. {
    3. Q_OBJECT
    4. public:
    5. RowHeaderView(QWidget* parent=0) : QHeaderView(Qt::Vertical, parent) {
    6. setItemDelegate(&delegate);
    7. }
    8. protected slots:
    9. virtual void mouseDoubleClickEvent( QMouseEvent *me ) {
    10. QModelIndex index = model()->index(logicalIndexAt(me->x(), me->y()), 0);
    11. //openPersistentEditor(index);
    12. QLineEdit *lineEdit = new QLineEdit(this);
    13. //QItemDelegate *delegate = new QItemDelegate(this);
    14. //delegate->createEditor(lineEdit, QStyleOptionViewItem() , QModelIndex());
    15. delegate.setEditorData();
    16. };
    17. private:
    18. QItemDelegate delegate;
    19. };
    20.  
    21. MyTableWidget::MyTableWidget(int rows, int columns)
    22. : QTableWidget(rows, columns)
    23. {
    24. RowHeaderView *rowHeaderView = new RowHeaderView(this);
    25. setVerticalHeader(rowHeaderView);
    26. ...
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Editable table header

    Why not simply connect to QHeaderView::sectionDoubleClicked(int) signal?

Similar Threads

  1. Replies: 0
    Last Post: 10th November 2006, 14:46
  2. make each row of table widget not editable??
    By darpan in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2006, 11:22
  3. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 23:12
  4. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 14:50
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 12:03

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.