Results 1 to 5 of 5

Thread: how to emit double click on cell Signal in QTableView from right click menu

  1. #1
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question how to emit double click on cell Signal in QTableView from right click menu

    In my QTableView I have a model MyDataModel that inherits from QAbstractTableModel to which I have added the below method to be able to rename the item by double clicking it!!



    Qt Code:
    1. def flags(self, index):
    2. """ This method sets the text in the cell editor selected
    3. and editable and enabled.
    4. """
    5. return QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
    To copy to clipboard, switch view to plain text mode 

    But now I have also added a right click contextual menu on which i have added the rename option, so I want to trigger the double click behavior to rename the selected item the same way I did by double clicking it.

    How can I achieve that?

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

    Default Re: how to emit double click on cell Signal in QTableView from right click menu

    Call the edit() slot of the view with the respective model index.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to emit double click on cell Signal in QTableView from right click menu

    Quote Originally Posted by anda_skoa View Post
    Call the edit() slot of the view with the respective model index.

    Cheers,
    _
    I don't know how to do that, can you give an example...


    Added after 8 minutes:


    Do you mean like this
    Qt Code:
    1. self.connect(self, SIGNAL("edit()"), SLOT("renAction"))
    To copy to clipboard, switch view to plain text mode 
    Last edited by krystosan; 7th January 2014 at 16:42.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to emit double click on cell Signal in QTableView from right click menu

    Obviously the mention of "slot" got you confused, let me rephrase:
    call the view's edit() method, i.e. this one: http://qt-project.org/doc/qt-4.8/qab...view.html#edit

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    krystosan (11th January 2014)

  6. #5
    Join Date
    Nov 2012
    Posts
    35
    Thanks
    1
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to emit double click on cell Signal in QTableView from right click menu

    thanks
    Qt Code:
    1. elf.edit(self.selectionModel().currentIndex())
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Telling apart single click and double click in QTableView
    By jgirlich in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2013, 14:27
  2. Replies: 2
    Last Post: 16th July 2012, 12:40
  3. Open a pop up menu when right click on any cell of the table
    By katta_ashish in forum Qt Programming
    Replies: 4
    Last Post: 9th September 2010, 07:06
  4. Replies: 2
    Last Post: 11th January 2009, 23:24
  5. QTreeWidget double click signal
    By Pinco Pallino in forum Newbie
    Replies: 2
    Last Post: 18th November 2006, 16:37

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.