Results 1 to 2 of 2

Thread: QTableWidget - Unselect cell onClick outside of control

  1. #1
    Join Date
    Apr 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget - Unselect cell onClick outside of control

    Hello,
    What I want:
    I'm trying to implement the following behavior while using a class which derives from QtTableWidget:
    When the user clicks outside the control, no cell in the table should be selected or in focus.

    Current behavior:
    When the user clicks outside the control the selection square remains on the last edited cell, although it does not appear editable. If I type something in the cell does get edited though

    Setting I am using:
    setSelectionBehavior(QAbstractItemView::SelectItem s);
    setEditTriggers(QAbstractItemView::AllEditTriggers );
    setShowGrid(true);


    Any Ideas on how I can achieve this?

    Thanks,
    Yoni

  2. #2
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QTableWidget - Unselect cell onClick outside of control

    Try to subclass QTableWidget and override focusOutEvent method (it gets called when a widget looses focus). There you can try to clear selection (e.g. via clearSelection method).

Similar Threads

  1. QTableWidget cell clicked
    By Archa4 in forum Newbie
    Replies: 5
    Last Post: 6th April 2011, 13:08
  2. qtablewidget cell's x() , y()
    By BalaQT in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2010, 13:23
  3. Replies: 1
    Last Post: 25th May 2010, 15:44
  4. Many cell widget in QTableWidget
    By Benarez in forum Qt Programming
    Replies: 3
    Last Post: 21st January 2010, 08:02
  5. Replies: 1
    Last Post: 7th December 2009, 19:56

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.