Results 1 to 6 of 6

Thread: QTableView context menu

  1. #1
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableView context menu

    I want to show a context menu on a QTreeView. The function that the QTreeView provide is customContextMenuRequested(const QPoint &) Do you know any method in which I could decide if the user clicked on an item or on the empty space? The QTreeWidget control has a function for that itemAt(QPoint). Does QTreeView have something like that? Thanks a lot. I am pretty new to QT.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView context menu

    No, but in the slot connected to customContextMenuRequested you can check the model index returned by QTreeView::indexAt.

  3. #3
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView context menu

    My mistake. Not QTreeView i am using QTableView.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView context menu

    Same thing. Both QTableView and QTreeView are subclasses of QAbstractItemView, which exposes indexAt().

  5. #5
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QTableView context menu

    Thanks a lot. I was looking for function named itemAt()

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView context menu

    The views are model based so you want the model index in this case. If it is valid the you clicked on an item.

Similar Threads

  1. Custom QTreeWidgetItem context menu?
    By AaronMK in forum Qt Programming
    Replies: 4
    Last Post: 1st February 2010, 04:42
  2. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  3. Replies: 4
    Last Post: 25th June 2007, 20:40
  4. QTreeWidget Context Menu
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 11th May 2007, 11:24
  5. Misplaced Context Menu
    By kandalf in forum Qt Programming
    Replies: 6
    Last Post: 18th February 2007, 04:28

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.