Results 1 to 3 of 3

Thread: QTableWidget + setSelectionMode()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget + setSelectionMode()

    Hello all,

    i have a QTableWidget with 3 rows and 3 columns. When user clicks on a widget (they are widgets not items...) then the whole row in which the widget belongs is selected. For example, if i click on widget on cell (0,0) then the cells (0,0), (0,1) and (0,2) are selected. What i do is to find the row the widget belongs to and then do the following:
    table->setSelectionMode(QAbstractItemView::ContiguousSel ection); //in order to select the cells in the same row
    table->selectRow( RowWidgetBelongsTo );
    table->setSelectionMode(QAbstractItemView::SingleSelecti on); //in order to prevent user from selecting multiple cells

    The problem is that if the user presses the "shift" button when he clicks on a cell, then he is able to select multiple cells...
    Any ideas?

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget + setSelectionMode()

    You will probably have to redefine the key press event handling for this widget.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget + setSelectionMode()

    solution given:
    http://www.qtforum.org/article/35160...ctionmode.html

    (sorry if not allowed to do this)

Similar Threads

  1. Please help with QTableWidget.
    By chris_helloworld in forum Qt Programming
    Replies: 14
    Last Post: 1st July 2010, 14:00
  2. Help with QTableWidget
    By aarelovich in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2009, 12:22
  3. QTableWidget
    By rick_st3 in forum Newbie
    Replies: 12
    Last Post: 26th June 2008, 11:38
  4. QTableWidget
    By Afflicted.d2 in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2006, 03:42
  5. QTableWidget
    By chak_med in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2006, 15:53

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
  •  
Qt is a trademark of The Qt Company.